In some code I'm working on I created a JavaScript function that is applied solely to Arrays, and I thought I'd try adding it as a member function.
I added it like so:
Array.prototype.myfunc = function(a){
...
}
Which works fine for the most part. The problem I run into then is with a for-in loop. It includes that function in the loop. If I then type in this snippet:
var bar, foo = ['alpha', 'bravo', 'charlie'];
for(bar in foo) console.log(foo[bar]);
Then the output is along the lines of:
alpha
bravo
charlie
function myFunc(a){
...
}
So is there any way of doing this but avoiding it showing in the for-in loop?