그래..다 좋은데 그러면 문자열은?🙄
var str = 'Hello';
str = str.replace('H', 'y'); // replace의 return을 변수에 할당해줘야만 한다
console.log(str); // yello
str[0] = 'K'; // 인덱스로 접근해 수정 시도
console.log(str[0]); // y... 안된다 문자열은 배열처럼 인덱스로 각 문자에 접근할 수 있다
여러가지 속성이나 함수 등을 이미 갖고 있다
var str = 'string';
console.log(str.length); // 6
console.log(str.toUpperCase()); // STRING
console.log(str); // string, str은 불변이며, toUpperCase 결과가 원본에 반영되지는 않는다
원시 값을 할당 받은 변수는 값 전달만 가능하다
A변수에 B변수를 할당하면, 각 변수는 별개의 메모리를 바라본다
var score = 80;
var copy = score; // copy에는 주소 할당? 값 할당?
console.log(score); // 80
console.log(copy); // 80, 복사는 됐다
score = 100;
console.log(score); // 100
console.log(copy); // 80, score와 copy는 별개의 메모리를 사용하고 있다
var score = {
teamA: '99',
teamB: '100'
};
var copy = score;
console.log(score);
console.log(copy); // copy와 score는 같은 객체를 바라본다
score.teamB = 200;
console.log(score); // 200
console.log(copy); // 200

js에서는 참조에 의한 전달은 없지만, 원시 값과 객체의 동작을 설명하기 위해 편의상 구분한다
변수에 할당된 값을 복사하면 항상 새로운 메모리에 할당되며, 그 값이 원시 값인지 참조 값인지의 차이만 있다
var teamA = {
score: 99
};
var teamB = {
score: '99'
};
console.log("(1)", teamA == teamB); // false
console.log("(2)", teamA === teamB); // false
console.log("(3)", teamA.score == teamB.score); // true.. 엥..99와 '99'가 같다고???
console.log("(4)", teamA.score === teamB.score); // false