I'm writing a function to do some data filtering. I write this:
Array.prototype.keyFilter = function ()
{
var dta = this;
for ( i in dta )
{
console.log( dta[i] );
};
};
console.log( ['green','yellow','blue'].keyFilter('type') );
And the return is:
green
yellow
blue
function ()
{
var dta = this;
for ( i in dta )
{
console.log( dta[i] );
};
}
undefined
OK, I get the array data ...PLUS the function itself and an "undefined". How to get only the array data using Array.prototype ??
Thanks for any help.