Skip to content

Commit c7b1873

Browse files
authored
Update 100_JS_Que
1 parent 06cd655 commit c7b1873

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

100Questions/100_JS_Que

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,32 @@ console.log("smile" === "smile"); //true
104104
JSON.parse ?
105105
Parse JSON object to a JavaScript value // converting data into js object
106106
-------------------------------------------------
107-
107+
let name = "priya";
108+
function getName(){
109+
console.log(name); //Uncaught ReferenceError: Cannot access 'name' before initialization
110+
let name = "supriya";
111+
}
112+
getName();
113+
//Explaination : Hoisting used here. If we use VAR the can use variable before declare. But in LET we can't do that. LET/CONST need declaration first then can use it.
114+
--------------------------------------------------
115+
let name = "priya";
116+
function getName(){
117+
console.log(name); //priya
118+
}
119+
getName();
120+
//Explaination : Let is a block scope.Because of closures we can able to access name which is outside of a function with LET.
121+
--------------------------------------------------
122+
console.log((x => x)('I love')) //"I love"
123+
console.log(`${(x => x)('I love')} to program`) //"I love to program"
124+
//Explaination : Template Literal used here. We use here arrow function which is returning a string
125+
----------------------------------------------------
126+
function sumValues(x,y,z){
127+
return x+y+z;
128+
}
129+
sumValues(...[2,3,4]) //how to call a function so that output will be 9
130+
//Explaination : we can't do like this sumValues(2,3,4).
131+
----------------------------------------------------
132+
Que: 26:
108133

109134

110135

0 commit comments

Comments
 (0)