Top 10 JavaScript Interview Questions




Top 10 commonly Asked JavaScript Interview Questions and its possible answers.

Original source


35 responses to “Top 10 JavaScript Interview Questions”

  1. Hi, Nice tutorial!
    I have a question that is troubling me a lot;

    At 7:50 ,
    const c; // Is c by default set to undefined or not?

    becuase when i am directly doing just after writing const c;

    console.log(c); // error I am getting: (Uncaught SyntaxError: Missing initializer in const declaration)

    Why so?

    And when I tried the same with let:

    let c;
    console.log(c);// undefined I got!

    Again when I myself initialize like below:

    const c=undefined;
    console.log(c); //undefined is the answer

    Kindly help in this regard!

    And thank you very very much for your awesome awesome videos.

    Humble Request:
    Please create a video series on react-redux saga, where you develop a full fledged website components in react-redux!
    I already completed your react-redux starter course! Please create some advanced stuff ๐Ÿ™‚

  2. @techsith one more noticeable difference, can surprise a few folks, i.e., when we declare a variable using let in global scope, the variable doesn't become a property of the global object whereas variables declared with var would be present as a property on the global object..

    var t = "Property On Global object";

    let x = "Not a property on global object";

    console.log(t); //"Property On Global object"

    console.log(window.t); //"Property On Global Object"

    console.log(x); //"Not a property on global object"

    console.log(window.x); //undefined

    Although both the variables can be accessed by inner scopes to the global and at the global scope itself, but the variable declared with let keyword won't be available as a property to the global object.

    For more, check – http://www.ecma-international.org/ecma-262/6.0/#sec-global-environment-records

  3. Some questions from my interviews:
    1. How would you describe that even bubbling works?
    2. calc(1)(2) returns 3. How would you write that function?
    3. What do you know about ES7?
    4. What is a callback function and how would you write it?
    5. Adding an array to another array without using push. How would you do it?

  4. Hi Techsith could you please explain following code ?? I have been asked in one of the interviews for the output –

    function parent() {
    var numOne = 1;
    function child(){
    var numTwo = 2;
    }
    console.log("numOne and numTwo are ", numOne , numTwo );
    }
    parent();

    Thanks in advance

  5. A const declaration must have an explicit initialization
    If you want a const with the undefined value, you'd have to declare const c = undefined to get it.
    const c alone will throw a SyntaxError: Missing initializer in const declaration
    Reassign will throw TypeError: Assignment to constant variable.

  6. Nice video to augment all of the other great videos you create. One thing I noticed, and this is a technicality. When describing the difference between 'let' and 'var', you state that the definition of a 'var' is hoisted, but not the value. What you meant to say (I am certain) is that the DECLARATION is hoisted and not the definition. This is an important clarification that needs to be made. Keep up the good work!!

Leave a Reply