2吗?

2013-01-25 13:48:43 +08:00
 duhastmich
fn = function(){
console.log(1)
return function(){
console.log(3)
}
}

(function(){
console.log('2')
})()
2802 次点击
所在节点    JavaScript
7 条回复
0x0001
2013-01-25 13:53:00 +08:00
233
markmx
2013-01-25 13:56:03 +08:00
没看懂的路过 !

@0x0001 能解释一下吗?
undeflife
2013-01-25 14:08:09 +08:00
@markmx
这代码等于
fn = function(){
console.log(1)
return function(){
console.log(3)
}
}()()
luin
2013-01-25 14:12:04 +08:00
我曾经写过一篇文章,和这个很类似。代码中没加分号...
http://zihua.li/2012/03/javascript-three-questions/
第3题。
duhastmich
2013-01-25 14:17:19 +08:00
@undeflife
@luin 少了个分号,搞了个中午...
luin
2013-01-25 14:19:53 +08:00
@duhastmich 弄个jslint...
duhastmich
2013-01-25 21:07:51 +08:00
@luin 哈哈,一般写coffeescript

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/58759

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX