javascript - I am pushing items into an array but the script becomes unresponsive? -


i'm trying add array's members using loop.

why code cause unresponsive script?

var magicarray = {      arraymemeber: [1, 2, 3, 4, 5],      duplicate: function () {         (var = 0; < this.arraymemeber.length; i++) {             this.arraymemeber.push(this.arraymemeber[i]);         };     } };  console.log(magicarray.duplicate()); 

though i'm not sure why want this, avoid infinite loop have length first , iterate on original length of array.

var magicarray = {      arraymemeber: [1,2,3,4,5],      duplicate: function() {          var length = this.arraymemeber.length;          (var = 0; < length; i++) {             this.arraymemeber.push(this.arraymemeber[i]);         };     } };  console.log(magicarray.duplicate()); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -