Skip to content

Instantly share code, notes, and snippets.

@niusounds
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save niusounds/1bfa584da69fb35ac069 to your computer and use it in GitHub Desktop.

Select an option

Save niusounds/1bfa584da69fb35ac069 to your computer and use it in GitHub Desktop.
JavaScriptの配列操作
var a = [1, 2, 3, 4, 5];
// shift は先頭を取り出す
a.shift(); // -> 1
console.log(a); // -> [2, 3, 4, 5]
// push は末尾に入れる
a.push(111);
console.log(a); // -> [2, 3, 4, 5, 111]
// pop は末尾を取り出す
a.pop(); // -> 111
console.log(a); // -> [2, 3, 4, 5]
// unshift は先頭に入れる
a.unshift(88);
console.log(a); // -> [88, 2, 3, 4, 5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment