In this blog, we will see 10 very simple but must know interview Question and answers.
1. What is the relation between JavaScript and ECMA Script?
Javascript is a scripting language used for web or webapplication development whereas ECMA Script is a like a guideline and rules for Javascript.
2. What is Callback?
A callback is a JavaScript function passed to some other function as an argument which is to be executed after the main function has finished executing.
1. What is the relation between JavaScript and ECMA Script?
Javascript is a scripting language used for web or webapplication development whereas ECMA Script is a like a guideline and rules for Javascript.
2. What is Callback?
A callback is a JavaScript function passed to some other function as an argument which is to be executed after the main function has finished executing.
function callbackFun(x) {
console.log(x);
}
function mainFun(num, callback) {
console.log("Hi I am going to call callback");
callback(num);
}
mainFun(7, callbackFun);
3. What is Closure?
A closure is a feature in JavaScript where an inner function has access to the outer (enclosing) function's variables. Learn more about closure.
4. What is namespace in JavaScript?
Namespace is used for grouping the desired functions, variables etc. under a unique name. This improves modularity in the coding and enables code reuse
5. Is JavaScript case sensitive?
Yes, JavaScript is case sensitive. For example, a variable x is not same as the variable X.
6. Define event bubbling?
JavaScript allows DOM elements to be nested inside each other. In such a case, if the handler of the child is clicked, the handler of parent will also work as if it were clicked too.
7. What is the 'Strict' mode in JavaScript and how can it be enabled?
Under the strict mode, JavaScript adds checks and shows errors for a piece of codes that might be problematic and potentially unsafe.For example, when you we use strict mode, we cannot use implicitly declared variables, or assign a value to a read-only property, or add a property to an object that is not extensible.
We can enable strict mode by adding “use strict” at the beginning of a file or a function.
8. What is the difference between Call & Apply?
The call() method calls a function with a given this value and arguments provided individually.
e.g.
fun.call(thisArg[, arg1[, arg2[, ...]]])
The apply() method calls a function with a given this value, and arguments provided as an array.
fun.apply(thisArg, [argsArray])
A closure is a feature in JavaScript where an inner function has access to the outer (enclosing) function's variables. Learn more about closure.
4. What is namespace in JavaScript?
Namespace is used for grouping the desired functions, variables etc. under a unique name. This improves modularity in the coding and enables code reuse
5. Is JavaScript case sensitive?
Yes, JavaScript is case sensitive. For example, a variable x is not same as the variable X.
6. Define event bubbling?
JavaScript allows DOM elements to be nested inside each other. In such a case, if the handler of the child is clicked, the handler of parent will also work as if it were clicked too.
7. What is the 'Strict' mode in JavaScript and how can it be enabled?
Under the strict mode, JavaScript adds checks and shows errors for a piece of codes that might be problematic and potentially unsafe.For example, when you we use strict mode, we cannot use implicitly declared variables, or assign a value to a read-only property, or add a property to an object that is not extensible.
We can enable strict mode by adding “use strict” at the beginning of a file or a function.
8. What is the difference between Call & Apply?
The call() method calls a function with a given this value and arguments provided individually.
e.g.
fun.call(thisArg[, arg1[, arg2[, ...]]])
The apply() method calls a function with a given this value, and arguments provided as an array.
fun.apply(thisArg, [argsArray])
9. What would be the result of 4+2+"7"?
Since 4 and 2 are integers, they will be added numerically. So we will get 6, then 7 is a string, its concatenation will be done. So finally we will get 67.
10. What is the use of isNaN function?
isNan function returns true if the argument is not a number. It's used to ckecking if the argument passed is a number.
Since 4 and 2 are integers, they will be added numerically. So we will get 6, then 7 is a string, its concatenation will be done. So finally we will get 67.
10. What is the use of isNaN function?
isNan function returns true if the argument is not a number. It's used to ckecking if the argument passed is a number.
I hope you guys must have liked these question. Feel free to ask question by writing down in comment section. Subscribe and leave your comment to support.
Thank you !!
Comments
Post a comment