JavaScript 배열 filter()

1 개요[ | ]

JavaScript array_filter()
let arr = ['foo', false, -1, null, ''];
let output = arr.filter(x=>x);
console.log( output ); // ["foo", -1]
let arr = ['foo', false, -1, null, ''];
console.log( arr.filter( function(a){ return a; } ) ); // ["foo", -1]
function array_filter(arr) { return arr.filter( function(a){ return a; } ) }
var arr = ['foo', false, -1, null, ''];
console.log( array_filter(arr) );
// ["foo", -1]
arr = [1, 4, 3, 2, 1, 2, 3, 2]
console.log( arr.filter(num => num === 2) )
// [ 2, 2, 2 ]

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}