# 配列の指定した位置に値を挿入する(Array.insertAt) > 指定された位置に値を挿入し、長さを 1 つ増やします。 - カテゴリ:配列(arrays) - ブロック:配列 の0 番目に0 を挿入する - URL:https://makecode.minecraft-okinawa.com/reference/arrays/insert-at/ - Pythonでの名前:Array.insert_at - 公式データ取得日:2026-11-13 - 動作確認:確認待ち ## JavaScript ```javascript [0].insertAt(0, 0) ``` ## Python ```python [0].insert_at(0, 0) ``` ## 引数 | 名前 | 値 | 意味 | |---|---|---| | index | 数値 | 値を挿入するリスト中の位置を 0 から始まる値で指定します。たとえば:0 | | value | T | | ## 使用例 ### The size of the array grows by one. The element is added to the array at the position you want. If there's an element already at that position, then it and all the other elements after it are moved (shifted) to the next higher position. So, an array that has the numbers 4, 5, 9, 3 will be 4, 5, 9, 2, 3 if 2 is inserted at position 3. It looks like this in blocks: ```javascript let myNumbers = [4, 5, 9, 3]; myNumbers.insertAt(3, 2); ``` ```python myNumbers = [4, 5, 9, 3] myNumbers.insert_at(3, 2) ``` ### Make a ordered array that has the numbers from a jumbled an array in order of lowest to highest. ```javascript let removed = 0 let jumbled = [4, 5, 2, 1, 6, 9, 0, 3, 8, 7] let ordered = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] for (let item of jumbled) { ordered.insertAt(item, item) removed = ordered.removeAt(item + 1) } ``` ```python removed = 0 jumbled = [4, 5, 2, 1, 6, 9, 0, 3, 8, 7] ordered = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] for item in jumbled: ordered.insert_at(item, item) removed = ordered.remove_at(item + 1) ``` ## 出典 - [MakeCode for Minecraft 公式リファレンス(Array.insertAt)](https://minecraft.makecode.com/reference/arrays/insert-at) 執筆:鈴木孝昌(現役プロジェクトマネージャー/マイクラカップ指導者)/運営:沖縄マイクラ部 プログラミングスクール「クロスウェーブ」(https://minecraft-okinawa.com/)