slice2 [TIL] 배열(Array) 메소드: length, push, pop, shift, unshift, Array.isArray, indexOf, includes, concat, join, slice javascript의 배열에 대해 정리해 보자 배열은 무엇인가? 한 마디로 순서가 있는 값이다. let arr = [ 1, 2, 3, 4, 5]; 대괄호(square bracket)를 이용해 element들을 그 안에 넣고, comma로 각 element를 구분한다. 배열에는 원본이 수정되는 메소드가 있고, 원본이 수정되지 않는 메소드가 있다. 기존의 배열을 수정하는 메소드: push, pop, shift, unshift 기존의 배열을 수정하지 않는(원본유지) 메소드: slice, split, join, concat 배열의 길이를 알기 위해서는 length를 사용하면 된다. let arr = [ 1, 2, 3, 4, 5]; arr.length; //5 push, pop, shift, unshift: pu.. 2021. 3. 9. [TIL] 문자열(String) 메소드: length, indexOf, substring, slice, split, includes, toLowerCase(), toUpperCase(), 2021.3.3 str[index] : 한 글자씩 index의 글자를 가져온다. let str = 'hello world'; console.log(str[0]); //h console.log(str[1]); //e console.log(str[100]); //undefined concatenating strings: + 연산자를 통해 string 타입과 다른 타입을 +연산자를 통해 concat할 경우 string 타입으로 변환된다. let str1 = 'hello'; let str2 = 'world'; console.log(str1+str2); //helloworld console.log(1+'1'); // 11 console.log(str1+'3'); hello3 str.length: 문자열의 전체 길.. 2021. 3. 3. 이전 1 다음