This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var array = ['b', 'c', 'd']; | |
| array.unshift('a'); | |
| console.log(array); // ['a', 'b', 'c', 'd'] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var array = ['b', 'c', 'd']; | |
| array.push('a'); | |
| console.log(array); // ['a', 'b', 'c', 'd', 'a'] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var array = ['a', 'b', 'c']; | |
| array.splice(1, 0, '1'); // 二番目に挿入 | |
| console.log(array); // ['a', '1', 'b', 'c'] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var array = ['a', 'b', 'c']; | |
| array.splice(3, 0, '1', '2'); // 三番目に複数挿入 | |
| console.log(array); // ['a', 'b', 'c', '1', '2'] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var array=['a', 'b', 'c']; | |
| var result=array.concat('d'); | |
| //非破壊的に要素を追加しその配列を返す | |
| console.log(array); // ['a', 'b', 'c'] | |
| console.log(result); // ['a', 'b', 'c', 'd'] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var array1 = ['a', 'b']; | |
| var array2 = ['c', 'd']; | |
| Array.prototype.push.apply(array1, array2); | |
| console.log(array1); // ['a', 'b', 'c', 'd'] | |
| console.log(array2); // ['c', 'd'] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var array = ['a', 'b', 'c']; | |
| var arr0 = array[0]; | |
| var arr1 = array[1]; | |
| var arr2 = array[2]; | |
| console.log(array); // ['a', 'b', 'c'] | |
| console.log(arr0); // 'a' | |
| console.log(arr1); // 'b' | |
| console.log(arr2); // 'c' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var array = ['a', 'b', 'c']; | |
| var value = array[array.length - 1]; | |
| console.log(array); // ['a', 'b', 'c'] | |
| console.log(value); // 'c' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var array = ['a', 'b', 'c']; | |
| var len = array.length; | |
| console.log(len); // 3 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var array = ['a', 'b', 'c']; | |
| var index = array.indexOf('b'); | |
| console.log(index); // 1 | |