JSFiddle

  • avoid-using-with-statement

    No-Library (pure JS), HTML, CSS, JavaScript

    /**
     * with 语句用于设置代码在特定对象中的作用域
     *
     * @link http://www.ecma-international.org/ecma-262/5.1/#sec-12.10
     *
     * 缺点:
     * 可读性差 (难以定位标志符所属的作用域)
     * 效率低 (遍历对象原型链)
     *
     *
     * strict 模式下不允许使用
     */
    var ...
  • question-1

    No-Library (pure JS), HTML, CSS, JavaScript

    /**
     * 1
     */
    var foo = function bar() {
      return 'bar'   
    }
    
    
    console.log(typeof foo)
    console.log(typeof bar)
  • question-2

    No-Library (pure JS), HTML, CSS, JavaScript

    /**
     * 2
     */
    function foo() {
    
      function bar() { return 1 }
    
      return bar
    
      function bar() { return 2 }
    }
    
    console.log(foo())
  • question-3

    No-Library (pure JS), HTML, CSS, JavaScript

    /**
     * 3
     */
    var ret = (function foo() { return 'foo' }, function bar() { return 'bar' })()
    
    console.log(ret)