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

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -