JAVASCRIPT
1> Difference between var and let in javascript
--- var is scoped to the nearest function block while let is enclosed to the nearest enclosing block.
--- Both are global if outside any block.
> const statement values can be assigned once and they cannot be reassigned.
example:
function nodeSimplified(){
const MY_VARIABLE =10;
console.log(MY_VARIABLE); //output 10
MY_VARIABLE =20; //throws type error
console.log(MY_VARIABLE);
}
2> Difference between == and ===
Ans: == just compares value while === compares value and type both.
3> what is the difference between "undefined" and "null" keywords?
--- undefined means variable has been declared but has not been assigned a value.
While null can be assigned to variable representing no value.
null === undefined // false
null == undefined // true
if we do typeof undefined it gives undefined while if we do typeof null it gives object.
Q.what is use of Arrow function?
Ans.
No comments:
Post a Comment