일부 데이터 필터링을 수행하는 함수를 작성하고 있습니다. 나는이 쓰기 :배열 데이터 만 반환 Array.prototype을 사용하여 함수 자체를 반환하지 않고
Array.prototype.keyFilter = function()
{
var dta = this;
for (i in dta)
{
console.log(dta[i]);
};
};
console.log(['green','yellow','blue'].keyFilter('type'));
을 그리고 반환은 다음과 같습니다
green
yellow
blue
function()
{
var dta = this;
for (i in dta)
{
console.log(dta[i]);
};
}
undefined
OK, 나는 배열 데이터를 얻을 수 ... PLUS 함수 자체와 "정의되지 않은". Array.prototype을 사용하여 배열 데이터 만 얻는 방법 ??
도움 주셔서 감사합니다.
'for ... in'이 아닌 배열을 반복하기 위해서는 보통'for' 루프를 사용해야합니다 – elclanrs