配列方法
9129 ワード
.push() //배열의 끝에 추가
.pop() //배열의 끝을 제거
.shift() //배열의 시작을 제거
.unshift() //배열의 시작을 추가
.concat()接合 const array1 = {a, b, c};
const array2 = {d, e, f};
const array3 = array1.concat(array2);
console.log(array3); // {a, b, c, d, e, f}
.includes( ) const array = {1, 2, 3};
console.log(array.includes(2)}; // true
console.log(array.includes(5)}; // false
.indexOf( ) const array = {‘coffee’, ‘tea’, ‘ice-cream’};
console.log(array.indexOf(‘tea’)); // 1
console.log(array.indexOf(‘coffee’)); // 0
console.log(array.indexOf(‘hot-choco’)) // -1
.reverse( ) const array = {1, 2, 3};
array.reverse(); // 3, 2, 1
.slice( ) const array = {‘a’, ‘b’, ‘c’, ‘d’, ‘e’};
array.slice(1); // ‘b’, ‘c’, ‘d’, ‘e’
array.slice(1, 4); // ‘ b’, ‘c’, ‘d’
array.slice(-2); // ‘d’, ‘e’
.splice( ) const weekend = {‘Mon’, ‘Wed’, ‘Thu’, ‘Fri’, ’Sat’};
weekend.splice(1, 0, ’Tue’); // Mon, Tue, Wed, Thu, Fri, Sat (Tue추가)
weekend.splice(5, 1, ’Sun’); // Mon, Tue, Wed, Thu, Fri, Sun (Sat—>Sun 변경)
weekend.splice(5,0); // Mon, Tue, Wed, Thu, Fri (Sun 삭제)
Reference
この問題について(配列方法), 我々は、より多くの情報をここで見つけました https://velog.io/@99per/배열-메서드テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol