- 문자열
- 사용하는 대부분의 문자열
- 영어, 일본어, 한국어 상관 없음
✍입력
let greeting = 'Hello world' let myName = 'Code Kim'
console.log(greeting) console.log(myName)
💻출력
"Hello world" "Code Kim"
✍입력
let greeting = 'Hello world' let myName = 'Code Kim'
console.log('hello world' + ' ' + 'code kim') console.log('good bye'+' '+'world')
💻출력
"hello world code kim" "good bye world"
※ 더하기 연산자 앞뒤로 있는 공백은 출력에 영향 없음
✍입력
let greeting = 'Hello world' let myName = 'Code Kim'
console.log(greeting +' ' + myName)
💻출력
"Hello world Code Kim"
✍입력
console.log(2+2) console.log(22) console.log( '2' + '2' ) console.log(2+"2")
💻출력
4 22 "22" "22"
- 숫자열 22는 문자열 "22"와 같지 않다
- number + string = string 데이터 타입으로 표현됨
✍입력
const myString = 'Hello! wecode!!' console.log(myString.length)
💻출력
15
✍입력
console.log("The length of pepsi is ", 'pepsi'.length )
💻출력
"The length of pepsi is " 5
✍입력
console.log("The length of pepsi is " + 'pepsi'.length)
💻출력
"The length of pepsi is 5"
※ 아래는 문자열+숫자열=문자열로 표현