array.prototype.remove()
testing array.prototype.remove()
by Terrance Smith
HTML
<button id="tester">TESTER
</button>
JavaScript
// Array Remove - By John Resig (MIT Licensed)
//http://ejohn.org/blog/javascript-array-remove/
Array.prototype.remove = function(from, to) {
"use strict";
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};
function removeStuff(){
debugger;
var testArr= ["v","a","l","u","e", " ","h","e","r","e"];
var expectedResult= ["v","a","l","u","e"];
var testArrResult = testArr.remove(4,testArr.length-1);
ok(testArrResult===expectedResult,"removes last 5 indexes of the array");
}
document.getElementById("tester").onclick=removeStuff();