javascript - how can I force the for .. in to display indexes and not prototype members -


i have array , custom prototype function:

var arr = ['a','b','c'], indexes = []; array.prototype.each = function() {/* code */}; 

// try iterate using .. in construct:

for (var index in arr) {    console.log(index); } 

in console.log, indexes 0-2 , key "each".

you can use foreach

arr.foreach(function(val){    console.log(val); }); 

for more see this , this


Comments

Popular posts from this blog

android - How to save instance state of selected radiobutton on menu -

python 3 IndexError: list index out of range -

IF statement in MySQL trigger -