Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
"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