• Blogs (9)
    • 📱 236 - 992 - 3846

      📧 jxjwilliam@gmail.com

    • Version: ‍🚀 1.1.0
  • JavaScript interview questions and answers

    Blogs20142014-12-19


    JavaScript interview questions and answers

    1. http://www.toptal.com/javascript/interview-questions
    2. http://www.reddit.com/r/javascript/comments/1x646n/tricky_javascript_web_quiz/
    function bar() {
        return foo;
        foo = 10;
        function foo() {}
        var foo = '11';
    }
    alert(typeof bar());
    /**
    This one is a little trickier. In Javascript, function declarations are
    hoisted to the top of the function in which they are declared.
    This simply means that you can call a function that was declared at a
    later time, provided this function was declared in the same block scope.
    So when bar() executes, the reality will look a bit like this:
    */
    function bar() {
        function foo() {}
        return foo;
        foo = 10;
        var foo = '11';
    }
    alert(typeof bar());
    /**
    Now it's become simple. When we call bar, the function foo is declared.
    Then we simply return foo. The rest of 'bar' is not executed.
    That's why the output will be "function".*/

    More at https://gist.github.com: https://gist.github.com/williamjxj/660234f9579b38e2e978.js