Skip to content

Commit 696c134

Browse files
authored
Update 100_JS_Que
1 parent 9acbf08 commit 696c134

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

100Questions/100_JS_Que

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,9 +688,49 @@ localStorage.setItem("testAsKey", user) //[object Object] beacuse we are forcefu
688688

689689
JSON.parse(localStorage.getItem("testAsKey")) //will get as a object
690690
------------------------------------------------------------------------------------------
691+
const user = {
692+
name :"priya",
693+
age : 100
694+
}
695+
console.log(JSON.stringify(user,["name"])) //"{'name':'priya'}"
691696

697+
//wheen we pass as a array then it will convernt only those properties and ignore rest of the proerties
698+
------------------------------------------------------------------------------------------
699+
const shape = {
700+
radius : 10,
701+
diameter(){
702+
return this.radius*2; //this pointing to shape
703+
}
704+
parimeter : () => 2*Math.PI*this.radius; //this pointing to window where it's not exist
705+
}
706+
console.log(shape.diameter()) //20
707+
//console.log(shape.parimeter()) //Nan
708+
-------------------------------------------------------------------------------------------
709+
let user = {
710+
name : "Priya",
711+
age : 100
712+
}
713+
714+
const name = "Supriya";
715+
//const {name} = user; //Identifier 'name' has already been declared
716+
const {name : myName} = user;
692717

718+
console.log(myName) //Priya
719+
-------------------------------------------------------------------------------------------
720+
let user = {
721+
age : 100,
722+
fullName : {
723+
first : "Priya",
724+
last : "Bagde"
725+
}
726+
}
693727

728+
const {fullName : {first}} = user;
729+
console.log(first); //"Priya"
730+
//Destructuring at deep nested
731+
-------------------------------------------------------------------------------------------
732+
733+
-------------------------------------------------------------------------------------------
694734

695735

696736

0 commit comments

Comments
 (0)