小智 10

在)

例子:

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

const result = words.filter(word => isBig(word));

function isBig(word){
  	console.log("called");
	return word.length > 6;
}
Run Code Online (Sandbox Code Playgroud)

输出:

“被叫”“被叫”“被叫”“被叫”“被叫”“被叫”数组[“旺盛”,“毁灭”,“现在”]

  • 考虑到它只有一行代码,并且您可以在线性时间内迭代大数组,这实际上是疯狂的。 (2认同)
  • 不知道这有什么疯狂的。由于抽象,它是一行,并且 O(n) 是线性时间...... (2认同)