Nodejs forEach

數組對象支持 forEach:

> a = ['1','2','3','4']
[ '1', '2', '3', '4' ]
> a.forEach(function(item){console.log(item)})
1
2
3
4

數組對象不支持 each:


> a
[ '1', '2', '3', '4' ]
> a.each(function(item){console.log(item)})
TypeError: undefined is not a function
    at repl:1:3
    at REPLServer.defaultEval (repl.js:132:27)
    at bound (domain.js:254:14)
    at REPLServer.runBound [as eval] (domain.js:267:12)
    at REPLServer.<anonymous> (repl.js:279:12)
    at REPLServer.emit (events.js:107:17)
    at REPLServer.Interface._onLine (readline.js:214:10)
    at REPLServer.Interface._line (readline.js:553:8)
    at REPLServer.Interface._ttyWrite (readline.js:830:14)
    at ReadStream.onkeypress (readline.js:109:10)

Nodejs 之 forEach
http://blog.csdn.net/jklfjsdj79hiofo/article/details/7847249

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章