선언(Declaration)
변수(Variable)는 이름이 붙은 저장소.
변수는 컴퓨터 메모리에 자리를 잡게 되고, 자리 잡는 동작을 변수 선언(Declaration)이라 한다.let variableName;
할당(Assignment)
어떤 값(value)를 넣을 수 있는 자리를 컴퓨터 메모리에 미리 잡아두었다 = 선언;
잡아둔 메모리에 값을 넣는것 = 할당;variavleName = 'value'; // value 값으로는 문자열, 숫자, 불리언 등 다양한 타입 가능
문자열
const a = 'ajrfyd'; console.log(a[0]); // 배열과 같이 값은 조회(접근)가능 하지만 수정 불가. Read Only
* str1.concat(str2) * const a = "ajrfyd"; const b = "bjrfyd"; console.log(a + b); << 이것과 console.log(a.concat(b)); << 이것은 같다.
* str.length * const a = 'ajrfyd'; console.log(a.length); // 6 '문자열!!!!!'의 길이를 구할때 씀!
* str.indexOf(searchValue) & str.lastIndexOf(searchValue) * const a = 'ajrfyd'; console.log(a.indexOf('a'); // 0; console.log(a.indexOf('rf'); // 2;
* str.includes(searchValue) * const a = 'ajrfyd'; console.log(a.includes('ajr')); // true;
* str.split(sepetator) * const b = 'There is an apple.'; console.log(b.split('')) // (18) ["T", "h", "e", "r", "e", " ", "i", "s", " ", "a", …] console.log(b.split(' ')) // (4) ["There", "is", "an", "apple."] ** 배열 형태로 반환됨. const a = `연도,제조사,모델,설명,가격 1997,Ford,E350,"ac, abs, moon",3000.00 1999,Chevy,"Venture ""Extended Edition""","",4900.00 1999,Chevy,"Venture ""Extended Edition, Very Large""",,5000.00 1996,Jeep,Grand Cherokee,"MUST SELL! air, moon roof, loaded",4799.00`; --- const b = a.split("\n"); console.log(b); const c = b[0].split(',') console.log(c); // (5) ["연도", "제조사", "모델", "설명", "가격"] ---
* str.subString(start, end) * const a = 'ajrfyd'; console.log(a.substring(0, 3)); // ajr
* str.slice() *
* str.trim() *
** 모든 string method는 IMMUTABLE로 원래 값을 변경하지 않음.