Skip to content

Commit 9488565

Browse files
authored
Update 100_JS_Que
1 parent c7b1873 commit 9488565

1 file changed

Lines changed: 150 additions & 1 deletion

File tree

100Questions/100_JS_Que

Lines changed: 150 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,156 @@ function sumValues(x,y,z){
129129
sumValues(...[2,3,4]) //how to call a function so that output will be 9
130130
//Explaination : we can't do like this sumValues(2,3,4).
131131
----------------------------------------------------
132-
Que: 26:
132+
const name = "priya is a girl.";
133+
console.log(typeof name); //string
134+
console.log(!typeof name); //false
135+
console.log(!typeof name === 'object'); //false
136+
console.log(!typeof name === 'string'); //false
137+
console.log(!typeof name === false); //true
138+
//Explaination : We are using negation mark(!) which will return either true or false only.
139+
----------------------------------------------------
140+
const name = "priya";
141+
const age ="10000";
142+
console.log(isNaN(name)); //true
143+
console.log(isNaN(age)); //false
144+
//Explaination : If it's not a number then return True. If it's a number then return false.
145+
-----------------------------------------------------
146+
let person = {name: "priya"};
147+
Object.seal(person); //post seal, how can you modify the person object
148+
person.age ="1000";
149+
person.name ="supriya";
150+
console.log(person); //{name : "supriya"}
151+
//Explaination : Onceyou use Seal we can't able to add the more keys with values into it.But you can modigy the existing key.
152+
-------------------------------------------------------
153+
let data = [2,9,0,10];
154+
data.shift();//remove first element
155+
console.log(data); //[9,0,10]
156+
data.pop(); //remove last element
157+
console.log(data);//[9,0]
158+
//Explaination : shift and pop use to remove the elements from first and last index.
159+
--------------------------------------------------------
160+
//check the value is even or odd
161+
let a =10;
162+
console.log(a%2===0 ? true : false); //true
163+
//Explaination : Need to divide by 2 and then checking if reminder is zero/one.
164+
----------------------------------------------------------
165+
let data ={ name : "priya"};
166+
delete data.name;
167+
console.log(data); //{}
168+
//Explaination : delete always work with object properties not a object itself.
169+
---------------------------------------------------------
170+
let data ="true";
171+
//convert data into boolean false value
172+
console.log(!data); //false
173+
console.log(typeof !data); //boolean
174+
//Explaination : ! will make boolean value(or opposite value).
175+
---------------------------------------------------------
176+
let data ="true";
177+
//convert data into boolean true value
178+
console.log(!!data); //true
179+
console.log(typeof !!data); //boolean
180+
//Explaination : ! will make boolean value(or opposite value).
181+
---------------------------------------------------------
182+
Diff between Map and foreach: Map will return new thing but Foreach didn't return anything.
183+
---------------------------------------------------------
184+
let data = ["piya", "priya", "supriya"];
185+
delete data[1];
186+
console.log(data); //["piya",,"supriya"] //["piya",empty,"supriya"]
187+
console.log(data.length); //3
188+
//Explaination : Whenever element deleted from an object it will create a empty space. Array length will always reain same.
189+
-------------------------------------------------------------
190+
//merge 2 arrays
191+
const a =[1,2,3];
192+
const b =[4,5,6];
193+
const c =[...a, ...b]
194+
console.log(c); //[1,2,3,4,5,6]
195+
//Explaination : using spread operator
196+
----------------------------------------------------------------
197+
const a =[1,2,3];
198+
const b =[3,4,5,6];
199+
const c =[...a, ...b]
200+
console.log(c); //[1,2,3,3,4,5,6]
201+
//Explaination : using spread operator still we can merge and both values will be present in arrays. But in an object, it will take the lates value and assigned to the 1st position of that key.
202+
-------------------------------------------------------------------
203+
let c = 3**3;
204+
console.log(c); //27
205+
console.log(3*3); //9
206+
//Explaination : 3 square 3 means 3*3*3
207+
---------------------------------------------------------------------
208+
let a=2;
209+
setTimeout(()=>{
210+
console.log(a); //100
211+
},0)
212+
a=100;
213+
//Explaination : Here we are using zero time interval. setTimeout is async function so it will execute at last. Firstly all the sync code will get execute. so that's why 100 is assigned to a.
214+
------------------------------------------------------------------------
215+
let a =2;
216+
let A =30;
217+
console.log(A); //30
218+
//Explaination : a and A both are diff variables.
219+
------------------------------------------------------------------------
220+
let A10="hello";
221+
let 10A ="hi";
222+
console.log(A10); //hello
223+
//console.log(10A); //error
224+
//Explaination : Variable can't start with a number.
225+
------------------------------------------------------------------------
226+
let a="hello";
227+
let b =`hello`;
228+
console.log(a === b); //true
229+
console.log(a == b); //true
230+
//Explaination : Doble code and backticks both are same.
231+
--------------------------------------------------------------------------
232+
233+
234+
235+
236+
237+
238+
239+
240+
241+
242+
243+
244+
245+
246+
247+
248+
249+
250+
251+
252+
253+
254+
255+
256+
257+
258+
259+
260+
261+
262+
263+
264+
265+
266+
267+
268+
269+
270+
271+
272+
273+
274+
275+
276+
277+
278+
279+
280+
281+
133282

134283

135284

0 commit comments

Comments
 (0)