references : https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/filter



Source


var words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];


const result = words.filter(word => word.length > 6);


console.log(result);


// expected output: Array ["exuberant", "destruction", "present"]



Example


function isBigEnough(value) {

  return value >= 10;

}

var filtered = [12, 5, 8, 130, 44].filter(isBigEnough);

// filtered: [12, 130, 44]


반응형

+ Recent posts