Pre Course Home Next

JavaScript Interview Questions Tutorial

JavaScript Interview Questions For Beginners

Q. What is the difference between var and let?
A. The difference between var and let is that var is function scoped and let is block scoped.

Q. Can we access var variable outside the block or in other block?
A. No, We can't access var variable outside the block, until its global.

Q. How we can define global variable in JavaScript?
A. We can use let or var keyword in the root (global scope), or we can use window reference.

// Below two variables are defined a global scope
var gloalVariableOne = "First global variable example";

let gloalVariableTwo = "Second global variable example";

function Hello(){
    // Below is the way to use window reference to define global variable inside a function local scope
    window.gloalVariableThree = "Second global variable example";
}

Q. What is isNaN in Javascript?
A.
In Javascript NaN stands for Not a number. isNaN is a function or method in JavaScript that returns boolean value based on if value is NaN or not. It will return true if value is NaN, otherwise it will return false.

Pre Course Home Next