reject

reject(iterator[, context]) -> Array

获取所有使 iterator 返回 false 的元素。

可选的 context 参数是 iterator 要绑定的对象,若设定该参数,iterator 中的 this 关键字将指向 context 对象。

样例

$R(1, 10).reject(function(n) { 
	return 0 == n % 2; 
}) 
// -> [1, 3, 5, 7, 9] 
[ 'hello', 'world', 'this', 'is', 'nice'].reject(function(s) { 
	return s.length >= 5; 
}) 
// -> ['this', 'is', 'nice'] 

参见

findAll 方法(别名 select)实现相反的功能。 如果需要根据指定的谓词将元素拆分为两组,请参考 partition