MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/b2o6f2/whats_your_favorite_most_useful_javascript/eiulbr9
r/javascript • u/Linux_is_awesome • Mar 18 '19
422 comments sorted by
View all comments
2
const obj = { foo: "john", bar : "doe"};
const {foo,bar} = obj;
1 u/SarahC Mar 19 '19 Is this how that one linker works with Math?const {abs, floor, random} = Math; console.log( abs(-5) );What's the technique called? 1 u/ovpv Mar 19 '19 yes. this should work. it's called Destructuring. check the link belowhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Basic_assignment 1 u/SarahC Mar 26 '19 Awesome! Thank you!
1
Is this how that one linker works with Math?
const {abs, floor, random} = Math; console.log( abs(-5) );
What's the technique called?
1 u/ovpv Mar 19 '19 yes. this should work. it's called Destructuring. check the link belowhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Basic_assignment 1 u/SarahC Mar 26 '19 Awesome! Thank you!
yes. this should work. it's called Destructuring. check the link below
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Basic_assignment
1 u/SarahC Mar 26 '19 Awesome! Thank you!
Awesome! Thank you!
2
u/ovpv Mar 19 '19
const obj = { foo: "john", bar : "doe"};
const {foo,bar} = obj;