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
let names = ["太郎", "二郎", "三郎"]; | |
for (let i < names.length; i++) { | |
console.log(names[i]); | |
} | |
取り出されるのは | |
太郎 | |
二郎 |
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
let names = ["太郎", "二郎", "花子", "三郎", '花子', "四郎"]; | |
let result = name.filter(name => name === '花子'); | |
console.log(result); | |
// ['花子', '花子'] | |
こうゆうのに主に使う | |
let nums = [1, 2, 3, 4, 5, 6]; |
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
let names = ["太郎", "二郎", "花子", "三郎", "四郎"]; | |
let result = name.find(name => name === '花子'); | |
console.log(result); | |
// 花子 |
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
let name = ["太郎", "二郎", "三郎"]; | |
name = []; | |
中身はこんな感じになる | |
[] | |
もう1つのやり方 |
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
let name = ["太郎", "二郎", "三郎"]; | |
name.splice(1,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
let name = ["太郎", "二郎", "三郎"]; | |
name.shift(); | |
中身はこんな感じになる | |
["二郎", "三郎"] |
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
let name = ["太郎", "二郎", "三郎"]; | |
name.pop(); | |
中身はこんな感じになる | |
["太郎", "二郎"] |
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
let name = ["太郎", "二郎", "三郎"]; | |
name.splice(1, 0, "花子"); | |
中身はこんな感じになる | |
["太郎", "花子", "二郎", "三郎"] | |
置き換えでは | |
let name = ["太郎", "二郎", "三郎"]; |
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
let name = ["太郎", "二郎", "三郎"]; | |
name.unshift("一郎"); | |
中身はこんな感じになる | |
["一郎", "太郎", "二郎", "三郎"] | |
数字も同じく | |
let number = [1, 2, 3, 4, 5]; |
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
let name = ["太郎", "二郎", "三郎"]; | |
name.push("四郎"); | |
中身はこんな感じになる | |
["太郎", "二郎", "三郎", "四郎"] | |
数字も同じく | |
let number = [1, 2, 3, 4, 5]; |
NewerOlder