๐Ÿ“
til
  • TIL(Today I Learned)
  • javascript
    • value-number-string-boolean-null-undefined
    • primitive-reference
    • Hoisting
    • Prototypes in Javascript
    • this
    • prototype
    • ์ฝœ๋ฐฑํ•จ์ˆ˜ (Callback function)
    • ํ•จ์ˆ˜์˜ ํ˜ธ์ถœ
    • ์ž๋ฃŒ๊ตฌ์กฐ new keyword
    • closure
    • Promise
    • event-loop
    • array-object
    • ๊ฐ์ฒด
    • Arguments
    • higher order function
    • operators-function-control-flow
    • ๊ฐ์ฒด ์ƒ์„ฑ ํŒจํ„ด 3๊ฐ€์ง€
    • Javascript scopes
    • Functional Programming
    • Design Patterns
    • ๋ฐ์ดํ„ฐ ํƒ€์ž…
    • Object ๊ฐ์ฒด
    • ํ‘œ์ค€ ๋‚ด์žฅ ๊ฐ์ฒด์˜ ํ™•์žฅ
    • ์ฐธ์กฐ
    • ํ•จ์ˆ˜
    • ์ƒ์†(Inheritance)
    • this - 'this'๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ํ•ด๋‹น ํ•จ์ˆ˜๋ฅผ '์–ด๋–ป๊ฒŒ' ์‹คํ–‰ํ•˜๋А๋ƒ์— ๋”ฐ๋ฅธ 4๊ฐ€์ง€ this ์ •์˜
    • ์ „์—ญ๊ฐ์ฒด(Global object)
    • ๊ฐ์ฒด ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ
    • The 'new' keyword - Object Creation in JavaScript
  • javascript-api
    • Number
      • Number.MAX_VALUE
      • Number.isInteger
      • Number.NEGATIVE_INFINITY
      • Number.isNaN()
      • Number.POSITIVE_INFINITY
      • Number.parseFloat
      • Number.EPSILON
      • number.toExponential
      • Number.MAX_SAFE_INTEGER
      • Number1 - ์ž์—ฐ์ˆ˜, ์ •์ˆ˜, 10์ง„์ˆ˜, 2์ง„์ˆ˜, ๋ถ€๋™์†Œ์ˆ˜์ , ์‹ค์ˆ˜
      • Number.isSafeInteger()
      • Number.MIN_VALUE
      • Number.parseInt
      • Number.NaN
      • Number.isFinite()
      • Number.MIN_SAFE_INTEGER
      • toFixed
    • string.split
    • String.fromCodePoint
    • string.trimEnd
    • string.padStart
    • string.@@iterator
    • String.fromCharCode
    • string.toUpperCase
    • string.codePointAt
    • string.toLowerCase()
    • string.toString
    • string.includes
    • string.replace()
    • string.charAt
    • String.lastIndexOf
    • string.slice
    • string.search
    • string.padEnd
    • string.substring
    • string.length
    • string.trim
    • string.localeCompare
    • String.indexOf
    • string.endsWith
    • string.valueOf
    • String.raw
    • string.matchAll()
    • string.repeat
    • string.match
    • String.prototype
    • string.startsWith
    • string.charCodeAt
    • string.trimStart
    • string.concat
    • string.toLocaleUpperCase()
    • string.toLocaleLowerCase
    • String
  • learn-node
    • debugger
    • Tip
  • schema-design
    • Database Schema Design
    • Database Schema Design
  • react
    • LifeCycle
    • redux
    • Context API
    • ํ•จ์ˆ˜ํ˜• ์ปดํฌ๋„ŒํŠธ์™€ ํด๋ž˜์Šค, ์–ด๋–ค ์ฐจ์ด๊ฐ€ ์กด์žฌํ• ๊นŒ?
    • Hooks๊ณผ useEffect ์‚ฌ์šฉํ•ด ๋ณด๊ธฐ
    • Route
    • async wait ์‚ฌ์šฉํ•˜๊ธฐ
    • Hooks API Reference
    • context
    • npm uninstall ํ•˜๋Š”๋ฒ•
    • test ๋งŒ๋“ค๊ธฐ
  • tip
    • ํด๋ฆฐ์ฝ”๋“œ
    • BxSlider๋กœ ํ…์ŠคํŠธ ํ๋ฅด๋Š” ํšจ๊ณผ ๋งŒ๋“ค๊ธฐ
  • javascript30
    • Event Capture, Propagation, Bubbling and Once
    • Object and Arrays - Reference VS Copy
  • typescript
    • ์šฐ์•„ํ•œ ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ 2๋ถ€
    • The Basic Cheatsheet
    • TypeScript
    • Type Guards and Differnetiating Types
    • ์šฐ์•„ํ•œ ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ
    • Generics
  • git-from-the-hell
    • git
    • init-status-add-commit-log-stage-repository
    • log-diff
    • ๋จธ์ง€ ํ›„ branch ์‚ญ์ œํ•˜๊ธฐ
    • ์ง€์˜ฅ์—์„œ ์˜จ Git
    • reset-revert
    • develop branch ๋ฅผ pull ํ•˜๊ณ  ์‹ถ์„๋•Œ
  • conference-and-seminar
    • ๋ชจ๋˜ ํ”„๋ก ํŠธ์—”๋“œ ๊ฐœ๋ฐœํ™˜๊ฒฝ์˜ ์ดํ•ด
  • fire-base
    • Firebase .gitignore
  • vanillacoding
    • Data Structures
    • Sorting Algorithms - part 1
    • Promise
    • class
    • 04.quiz
    • 07.event-loop
    • Design Patterns
    • OOP (Object Oriented Programming)
  • etc
    • ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ฝ”๋“œ๋ฆฌ๋ทฐ
    • ์Šค์Šค๋กœ ๊ณต๋ถ€ํ•˜๋Š” ๋ฒ•
    • ๋ฐ”๋‹๋ผ์ฝ”๋”ฉ ์ˆ˜๊ฐ• ํ›„๊ธฐ
    • async ๊ณผ์ œ ํ›„๊ธฐ - ๋น„๋™๊ธฐ, ๋™๊ธฐ, ํด๋กœ์ €, ๋ฐฐ์—ด๊ณผ ๊ฐ์ฒด
    • ์œ ์šฉํ•œ ์‚ฌ์ดํŠธ
  • algorithm
    • The Supermarket Queue
    • Find the odd int
    • The Office III - Broken Photocopier
    • Directions Reduction
    • The Office II - Boredom Score
    • Divisible Sum Pairs
    • Codewars ์ด์šฉ์ž ์†”๋ฃจ์…˜ ๋ชจ์Œ
    • Shortest Word
    • find key
    • Two Sum
    • Simple Pig Latin
  • Book
    • the essence of object-orientation
      • ํƒ€์ž…๊ณผ ์ถ”์ƒํ™”
      • ๊ฐ์ฒด ์ง€๋„
      • ์ด์ƒํ•œ ๋‚˜๋ผ์˜ ๊ฐ์ฒด
      • ์ถ”์ƒํ™” ๊ธฐ๋ฒ•
      • 05. ์ฑ…์ž„๊ณผ ๋ฉ”์‹œ์ง€
      • 07.ํ•จ๊ป˜ ๋ชจ์œผ๊ธฐ
      • 04. ์—ญํ• , ์ฑ…์ž„, ํ˜‘๋ ฅ
      • ํ˜‘๋ ฅํ•˜๋Š” ๊ฐ์ฒด๋“ค์˜ ๊ณต๋™์ฒด
  • ecma-script2015
    • Object Literal Upgrades
    • default-parameter-template-literals-arrow-functions
    • spread-operator-rest-param
    • let-const-rest-parameter-spread-operator-destructuring
  • http
    • ์›น ๋ธŒ๋ผ์šฐ์ €์— URL์„ ์ž…๋ ฅํ–ˆ์„ ๋•Œ ์–ด๋–ป๊ฒŒ ์›น ํŽ˜์ด์ง€๊ฐ€ ๋ณด์—ฌ์งˆ๊นŒ?
  • jest
    • toThrow(error?)
  • data-structures
    • Data Structures
  • express
    • express generator
    • CORS
  • css-flexible-box-layout
    • flex ํ•ด๋ฒ„๋ ธ์ง€ ๋ญ์•ผ
  • git
    • Git
  • mongodb
    • MongoDB
  • markdown
    • use-markdown
  • cmder
    • cmd ๋ช…๋ น์–ด ๋ชจ์Œ
  • debug
    • trackClicksEx function error
  • npm
    • NPM TOKEN ์„ค์ •ํ•˜๊ธฐ
  • storybook
    • Storybook
  • sort
    • Sorting Algorithms - part 1
  • javascript-koans
    • Javascript Koans ์˜ค๋‹ต๋…ธํŠธ
  • rxjs
    • Rx.js
  • dom-elements
    • HTML Element
  • redux-toolkit
    • Redux Toolkit
  • github-actions
    • GitHub Actions
  • redux-middleware
    • redux middleware
  • rest
    • rest
  • css-rendering
    • ์ฝ”๋“œ ์Šคํ”ผ์ธ  - CSS Rendering 1ํšŒ์ฐจ 2/2
    • ์ฝ”๋“œ ์Šคํ”ผ์ธ  - CSS Rendering 1ํšŒ์ฐจ 1/2
  • you-dont-know-js
    • ํƒ€์ž…
  • server
    • # shutdown local server
  • semantic-versioning
    • Semantic Versioning 2.0.0
Powered by GitBook
On this page
  • Syntax
  • Parameters
  • Return value
  • ์˜ˆ์™ธ
  • Description
  • String.raw() ์‚ฌ์šฉ
  • Browser compatibility

Was this helpful?

  1. javascript-api

String.raw

String.raw() ์ •์  ๋ฉ”์†Œ๋“œ๋Š” template Iiterals์˜ ํƒœ๊ทธ ํ•จ์ˆ˜์ด๋‹ค. Python์˜ r prefix์™€ ๋ฌธ์ž์—ด ๋ฆฌํ„ฐ๋Ÿด์˜ ๊ฒฝ์šฐ C#์˜ @ ์ ‘๋‘์‚ฌ์™€ ์œ ์‚ฌํ•˜๋‹ค. (๊ทธ๋Ÿฌ๋‚˜ ๋™์ผํ•˜์ง€ ์•Š์Œ) template ๋ฌธ์ž์—ด์˜ ์›์‹œ ๋ฌธ์ž์—ด ํ˜•ํƒœ, ๋Œ€์ฒด(์˜ˆ ${foo}) ์ฒ˜๋ฆฌ๊ฐ€ ๋˜์ง€๋งŒ ์ด์Šค์ผ€์ดํ”„(์˜ˆ: \n)๋Š” ์ฒ˜๋ฆฌ๋˜์ง€ ์•Š๋Š”๋‹ค.

// "C:Developmentprofileaboutme.html"
// raw๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์•˜์„ ๋•Œ
`C:\Development\profile\aboutme.html`;

// ๋ฐฑ์Šฌ๋ž˜์‹œ๊ฐ€ ๋น ์ง€์ง€ ์•Š๊ฒŒ ์œˆ๋„์šฐ ํŒŒ์ผ ๊ฒฝ๋กœ๋ฅผ ๋‹ด๋Š” ๋ณ€์ˆ˜๋ฅผ ๋งŒ๋“ค์–ด๋ผ
const filePath = String.raw`C:\Development\profile\aboutme.html`;


console.log('The file was uploaded from:' + filePath); // The file was uploaded from:C:\Development\profile\aboutme.html

Syntax

String.raw(callSite, ...substitutions)

string.raw`templateString`

Parameters

callSite

{ raw: ['foo', 'bar', 'baz'] } ๊ฐ™์ด ์ž˜ ํ˜•์„ฑ๋œ template๋ฅผ ํ˜ธ์ถœํ•˜๋Š” site object

...substitution

template string, ํ•„์š”ํ•œ ๊ฒฝ์šฐ ๊ต์ฒดํ•œ๋‹ค (${...}).

Return value

์ฃผ์–ด์ง„ template ๋ฌธ์ž์—ด์˜ ์›์‹œ ๋ฌธ์ž์—ด์ด๋‹ค.

์˜ˆ์™ธ

site object๊ฐ€ ์ž˜๋ชป๋œ ํ˜•์„ฑ์ด๋ฉด TypeError(๊ฐ’์ด ๊ธฐ๋Œ€ํ•˜๋˜ ์ž๋ฃŒํ˜•์ด ์•„๋‹ˆ๋ผ์„œ ์—ฐ์‚ฐ์„ ํ•  ์ˆ˜ ์—†์„ ๋•Œ ๋ฐœ์ƒํ•˜๋Š” ์˜ค๋ฅ˜) ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค.

Description

๋Œ€๋ถ€๋ถ„์˜ ๊ฒฝ์šฐ, String.raw() ๋Š” template string๊ณผ ๊ฐ™์ด ์‚ฌ์šฉ๋œ๋‹ค.

์œ„์—์„œ ์–ธ๊ธ‰ํ•œ ์ฒซ๋ฒˆ์งธ ๊ตฌ๋ฌธ์€ ๊ฑฐ์˜ ์‚ฌ์šฉ๋˜์ง€ ์•Š๋Š”๋‹ค. JavaScript ์—”์ง„์ด (๋‹ค๋ฅธ ํƒœ๊ทธ ๊ธฐ๋Šฅ๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ) ์ ์ ˆํ•œ ์ธ์ˆ˜๋กœ ํ˜ธ์ถœํ•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

String.raw() ํ…œํ”Œ๋ฆฟ ๋ฌธ์ž์—ด์˜ ์œ ์ผํ•œ built-in tag function์ด๋‹ค. ๊ธฐ๋ณธ ํ…œํ”Œ๋ฆฟ ๊ธฐ๋Šฅ๊ณผ ๋™์ผํ•˜๊ฒŒ ์ž‘๋™ํ•˜๋ฉฐ ์—ฐ๊ฒฐ์„ ์ˆ˜ํ–‰ํ•œ๋‹ค. JavaScript ์ฝ”๋“œ๋กœ ๋‹ค์‹œ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ๋‹ค.

String.raw() ์‚ฌ์šฉ

`Hi\n${2+3}!` /* "Hi
5!" */

String.raw`Hi\n${2+3}!`; 
// 'Hi' ๋‹ค์Œ์— ์˜ค๋Š” ๋ฌธ์ž์—ด์€ ์ค„๋ฐ”๊ฟˆ์ด ์ผ์–ด๋‚˜์ง€ ์•Š๋Š”๋‹ค.

`Hi\u000A!`; /* "Hi
!" */

String.raw`Hi/u000A!`; // String.raw`Hi\u000A!`;
// escape character(\', \", \\, \n, \r, \t, \b, \v, \0, \xFF)๋Š” ํšจ๊ณผ๊ฐ€ ์—†๋‹ค. ๋ฐฑ์Šฌ๋ž˜์‹œ๋„ ์ถœ๋ ฅ
// ๋ฌธ์ž์—ด์˜ .length ์†์„ฑ์„ ์‚ฌ์šฉํ•˜์—ฌ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

`Hi\u000A!`.length // 4
String.raw`Hi/u000A!`.length // 9

let name = 'Bob';
String.raw`Hi\n${name}!`; // "Hi\nBob!" ${name}๋Š” ์ฒ˜๋ฆฌ๊ฐ€ ๋œ๋‹ค. 

// ์ผ๋ฐ˜์ ์œผ๋กœ String.raw()๋ฅผ ํ•จ์ˆ˜๋กœ ํ˜ธ์ถœ ํ•˜์ง€ ์•Š๋Š”๋‹ค.
// 't${0}e${1}s${2}t'์„(๋ฅผ) ์‹œ๋ฎฌ๋ ˆ์ด์…˜ํ•˜๋ ค๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด.. 
String.raw({raw: 'test'}, 0, 1, 2); // "t0e1s2t"
// ๋ฌธ์ž์—ด์ธ 'test'๋Š” ๋ฐฐ์—ด๊ณผ ์œ ์‚ฌํ•œ ๊ฐ์ฒด์ด๋‹ค.

// `foo${2 + 3}bar${'Java' + 'Script'}baz`์— ํ•ด๋‹นํ•œ๋‹ค.
String.raw({raw: ['foo', 'bar', 'baz']}, 2 + 3, 'Java' + 'Script'); // "foo5barJavaScriptbaz"

Browser compatibility

IE ๋†‰, Opera ๋†‰, ์•ˆ๋“œ๋กœ์ด๋“œ ์›น๋ทฐ ๋†‰, ์•ˆ๋“œ๋กœ์ด๋“œ ์˜คํŽ˜๋ผ ๋†‰

Previousstring.valueOfNextstring.matchAll()

Last updated 5 years ago

Was this helpful?