为什么 JavaScript 中的对象没有 find 方法
why object in javascript does not have find method?
我开始node
repl 并输入了这个
> function isPrime(element, index, array) {
... var start = 2;
... while (start <= Math.sqrt(element)) {
..... if (element % start++ < 1) {
....... return false;
....... }
..... }
... return element > 1;
... }
undefined
> [4, 6, 8, 12].find(isPrime)
TypeError: Object 4,6,8,12 has no method 'find'
at repl:1:16
at REPLServer.self.eval (repl.js:110:21)
at Interface.<anonymous> (repl.js:239:12)
at Interface.EventEmitter.emit (events.js:95:17)
at Interface._onLine (readline.js:202:10)
at Interface._line (readline.js:531:8)
at Interface._ttyWrite (readline.js:760:14)
at ReadStream.onkeypress (readline.js:99:10)
at ReadStream.EventEmitter.emit (events.js:98:17)
at emitKey (readline.js:1095:12)
这是怎么回事?为什么数组对象没有 find
方法?不是和这里一样吗?
V8
暂时没有意识到.find()
数组方法(请参阅源代码)。所以node.js
和io.js
不支持它。请参阅兼容性表
相关文章:
- 他们是如何使用angular/jqLite find()方法按属性名称和值选择元素的?ng conf 2015
- strongloop script.js run find in before delete方法:如何同步运行异步方法
- Ember.js-模型find()方法中的异步调用
- Javascript find 方法在第一次匹配后不会停止
- Ember:使用this.get('controller.').content,find方法
- 如何等到find方法完成后再在Ember模型中进行进一步处理
- 为什么 JavaScript 中的对象没有 find 方法
- 如何在节点/环回中同步调用 model.find 方法
- Typerror:mongo 模块的 find 方法是未定义的
- 在jQuery中使用find方法时获取多个标记值
- jQuery get Inner
一张桌子的;使用.find()方法使用不同的类 - 如何使用jQuery's .find方法与正则表达式作为参数
- jQuery find()方法不能只在一个类上工作
- Jquery .find()方法——由逗号连接的dom组成的参数
- 从Mongoose find方法中的其他集合中获取数据
- Ember数据's find方法:处理SQL'或者'等效查询
- 通过Mongoose获取集合失败(Object{}没有'find'方法)
- 使用mongoose.find()方法在构造函数中设置javascript对象属性
- 为什么我的find方法返回undefined ?
- 在XML对象上没有find()方法