10 JavaScript Common Interview Questions
Q. What is the different between double equal(==) & triple equal(===)
Ans: In JavaScript, double & triple equals are used for comparison. Double equal is comparing values only. String 1 & Number 1 are same in double equal because there values are same. In other side, triple equal comparing values & data type. String 1 & Number 1 is aren’t same because values are same but data types different. So, main difference between double & triple equal is one is check values only and otherone check values, data type .
Q. What is Truthy and Falsy value?
Ans: In JavaScript, “false”, “0”, “NaN”, “undefined”, “null”, “empty string(“”)”, “-1” this are falsy values, otherwise everything else are truthly values. Falsy values is a value that considered false when encountered in boolean context, same as truthly value just considered true.
Q. What is between JavaScript library & Framework?
Ans: Library is a set of reuseable functions, we can control this functions. Otherside Frameworks is a piece of codes will helps us build architecture in our projects. so framework have so many code that we can use & build our website faster.
Q. What is difference between global & local variables?
Ans: Global variable is declare a variable without into a function or loops or comparison operator’s scope. Otherside local variable is declare a variable into any function scope or inside {} scope. the main difference between global & local is global variables are allow to access any type of scope, and locare variables are not.
Q. What is difference between null & undefined?
Ans: null is JavaScript data type which means any value or results have no value. Otherside undefined is also data type for you try to access something which isn’t declare your code. So, main difference is null is declared any variable but when you access it returns empty value & undifiend is you don't’t declare any variable but you try to access it.
Q. What is the main difference between Es5 & Es6?
Ans: Es5/Es6 are JavaScript versions where es5 released in 2009 and es6 in 2015. Es5 is most common for us and browser because it old and all browser have Usable. But Es6 have some features which are not usable all browser at this time. Es6 has new data type is called “symble” & some syntactic feature arrow function, restructuring, Classes, Map, Spread operator, new library promises.
Q. Why setTimeout() is useful?
Ans: setTimeout() is JavaScript method allows us to run a function once after the interval of time. I can handle delay time What I need. some time I need any function to call after 3 seconds, then setTimeout() is help me to solve this.
Q. What is setInterval()?
Ans: setInterval()is also JavaScript method which is similar to setTimeout() method but main difference is it allows us to run a function repeatedly, starting after the interval of time, then repeating continuously.
Q. What is Destructuring?
Ans: Destructure is JavaScript expression that allow us to unpack values from arrays or object properties. when we need to declare a variable one by one and every time need to assign arrays index or object property name is Waste time. So we can destructure any array or object to extract data in our new variables.
Q. What is function expression?
Ans: In JavaScript we can call a function with a name, but function expression has no name in the function, so we need to use this expression into a variable to reuse it future.