V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐关注
Meteor
JSLint - a JavaScript code quality tool
jsFiddle
D3.js
WebStorm
推荐书目
JavaScript 权威指南第 5 版
Closure: The Definitive Guide
duhastmich
V2EX  ›  JavaScript

2吗?

  •  
  •   duhastmich · 2013-01-25 13:48:43 +08:00 · 2746 次点击
    这是一个创建于 4132 天前的主题,其中的信息可能已经有所发展或是发生改变。
    fn = function(){
    console.log(1)
    return function(){
    console.log(3)
    }
    }

    (function(){
    console.log('2')
    })()
    7 条回复    1970-01-01 08:00:00 +08:00
    0x0001
        1
    0x0001  
       2013-01-25 13:53:00 +08:00
    233
    markmx
        2
    markmx  
       2013-01-25 13:56:03 +08:00
    没看懂的路过 !

    @0x0001 能解释一下吗?
    undeflife
        3
    undeflife  
       2013-01-25 14:08:09 +08:00
    @markmx
    这代码等于
    fn = function(){
    console.log(1)
    return function(){
    console.log(3)
    }
    }()()
    luin
        4
    luin  
       2013-01-25 14:12:04 +08:00
    我曾经写过一篇文章,和这个很类似。代码中没加分号...
    http://zihua.li/2012/03/javascript-three-questions/
    第3题。
    duhastmich
        5
    duhastmich  
    OP
       2013-01-25 14:17:19 +08:00
    @undeflife
    @luin 少了个分号,搞了个中午...
    luin
        6
    luin  
       2013-01-25 14:19:53 +08:00
    @duhastmich 弄个jslint...
    duhastmich
        7
    duhastmich  
    OP
       2013-01-25 21:07:51 +08:00
    @luin 哈哈,一般写coffeescript
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   925 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 22:47 · PVG 06:47 · LAX 15:47 · JFK 18:47
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.