Skip to content

Instantly share code, notes, and snippets.

@chuck0523
Created September 20, 2015 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuck0523/0944de52e843c21904f1 to your computer and use it in GitHub Desktop.
Save chuck0523/0944de52e843c21904f1 to your computer and use it in GitHub Desktop.
"use strict";
var log = function log(x) {
console.log(x);
};
var ary = [10, 23, 4, 0, 77];
var a = ary.splice();
log(ary); // [10, 23, 4, 0, 77]]
var ary = [10, 23, 4, 0, 77];
var b = ary.splice(3);
log(ary); // [10, 23, 4]
var ary = [10, 23, 4, 0, 77];
var c = ary.splice(2, 2);
log(ary); // [10, 23, 77]
var ary = [10, 23, 4, 0, 77];
var d = ary.splice(2, 3, 'nothing');
log(ary); // [10, 23, 'nothing']
var ary = [10, 23, 4, 0, 77];
var e = ary.splice(2, 3, 'nothing1', 'nothing2');
log(ary); // [10, 23, 'nothing1', 'nothing2']
var ary = [10, 23, 4, 0, 77];
var e = ary.splice(2, 3, 'nothing1', 'nothing2', 'nothing3');
log(ary); // [10, 23, 'nothing1', 'nothing2', 'nothing3']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment