配列の最後に値を追加する Array.push
ひとことで言うと
配列に新しい要素を追加します。
ブロックとコード
配列の最後に○を追加
ブロックの文言は公式の日本語版に合わせています(形は簡易表示です)。
[""].push("hello")[""].append("hello")引数(ひきすう)
引数とは、ブロックの中で自分で選んだり入力したりする部分のことです。
| 名前 | 選べる値 | 意味 |
|---|---|---|
| item | T |
使用例
You might have an array with 3 numbers, like 1, 2, and 3. If you want to add another number to the end, then you push it on to the array. You do it like this:
JavaScript
let thoseNumbers = [1, 2, 3];
thoseNumbers.push(4);Python
thoseNumbers = [1, 2, 3]
thoseNumbers.append(4)Add another animal to the end of your list of favorite pets.
JavaScript
let pets = ["cat", "dog", "parrot", "goldfish"];
pets.push("guinea pig");Python
pets = ["cat", "dog", "parrot", "goldfish"]
pets.append("guinea pig")