# 配列の最初の値を取り出す(Array.shift) > 配列から最初の要素を削除し、その値を返します。このメソッドは、配列の長さを変更します。 - カテゴリ:配列(arrays) - ブロック:配列 から最初の値を削除して返す - URL:https://makecode.minecraft-okinawa.com/reference/arrays/shift/ - 公式データ取得日:2026-11-13 - 動作確認:確認待ち ## JavaScript ```javascript [""].shift() ``` ## Python ```python [""].shift() ``` ## 使用例 ### If you have an array with 4 numbers, like 1, 2, 3, and 4, you remove the first number from the array by shifting it from the front. To shift the number from the array in blocks, do this: ```javascript let thoseNumbers = [1, 2, 3, 4]; let firstNumber = thoseNumbers.shift(); ``` ```python thoseNumbers = [1, 2, 3, 4] firstNumber = thoseNumbers.shift() ``` ### Find out how many odd numbers there are as you remove all the numbers from a list. ```javascript let odds = 0; let ints = [45, 78, 98, 3, 5, 6, 12, 643, 0, 34, 4]; while (ints.length > 0) { if ((ints.shift() % 2) > 0) { odds++; } } ``` ```python odds = 0 ints = [45, 78, 98, 3, 5, 6, 12, 643, 0, 34, 4] while len(ints) > 0: if (ints.shift() % 2) > 0: odds += 1 ``` ## 出典 - [MakeCode for Minecraft 公式リファレンス(Array.shift)](https://minecraft.makecode.com/reference/arrays/shift) 執筆:鈴木孝昌(現役プロジェクトマネージャー/マイクラカップ指導者)/運営:沖縄マイクラ部 プログラミングスクール「クロスウェーブ」(https://minecraft-okinawa.com/)