f_
frhyme.code
•javascript•⏱ 약 1분 소요

Javascript - String format

  • javascripnt에서 String 내에 변수를 위치시키는 방법을 정리합니다.
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8"/>
    </head>
    <body>
        <script>
            var x = "frhyme" // string
            var y = 10 // number
            var z = `${x} and ${y}` // string 

            console.log(`This is ${x}, ${y}, ${z}`);
            // This is frhyme, 10, frhyme and 10
            
            console.log("This is ${x}");
            // This is ${x}
        </script>
    </body>
</html>
GitHub에서 이 글의 마크다운 원본 보기 & 수정 제안src/content/posts/2021-02-02-javascript08_string_format

💡RELATED ARTICLES · 함께 읽으면 좋은 연관 포스트

글 주소가 클립보드에 복사되었습니다.