언어/JavaScript
따옴표와 백틱의 차이'',"",``
홍시_코딩기록
2023. 5. 24. 19:23
1."따옴표 사용했을 때"
const name = "Alice";
const greeting = "Hello, " + name + "!";
console.log(greeting); // 출력값: "Hello, Alice!"
2. `백틱 사용했을 때`
const name = "Alice";
const greeting = `Hello, ${name}!`;
console.log(greeting); // 출력값: "Hello, Alice!"
- `` 백틱을 사용하면 코드를 더 간결하게 쓸 수 있고 html작성할 때의 구조로도 작업 가능함.
예제는 gpt에서 가져옴,,