Javascript Array deleteAll()

Description

Javascript Array deleteAll()


Array.prototype.deleteAll = function(){
 var arr = this;//from   w  w w. ja  v a  2s.co  m
 arr.splice(0,arr.length);
}

var arr = [1,2,3,4,5];

var Button = function(){
    this.setElement = function(txt,id){
        var btn = document.createElement("button");
        var txt = document.createTextNode(txt);
        btn.appendChild(txt);
        btn.setAttribute("id",id);
        document.body.appendChild(btn);
    }
}

var startButton = new Button();
var quitButton = new Button();

startButton.setElement("txt 1","startButton");
quitButton.setElement("txt 2","quitButton");



PreviousNext

Related