Tapas Adhikary
Educator @tapaScript | Founder CreoWis & ReactPlay - Writer - YouTuber - Open Source
Introduction We use JavaScript objects to store data and retrieve it later. We store data(aka information) in key-value pairs. The key-value pair is also known as the object properties. Here is an employee object with three properties: id, name, dep...
blog.greenroots.info8 min read
Great article, I am a beginner in JavaScript and it was fun to learn this new syntax. I would like to add something.
In the following topic: ๐๐ฎ๐ป๐ฑ๐น๐ฒ ๐ฑ๐๐ป๐ฎ๐บ๐ถ๐ฐ ๐ป๐ฎ๐บ๐ฒ ๐ฝ๐ฟ๐ผ๐ฝ๐ฒ๐ฟ๐๐ ๐๐ถ๐๐ต ๐ผ๐ฏ๐ท๐ฒ๐ฐ๐ ๐ฑ๐ฒ๐๐๐ฟ๐๐ฐ๐๐๐ฟ๐ถ๐ป๐ด
where you created a function to get the key value dynamically, I thought of also adding the object as a parameter, so that we can deal with multiple objects and not hard code one object inside the function. Here is the code for the same :
function getPropertyValue(key,obj) { const {[key] : returnValue} = obj; return returnValue; }
const student = { name : "Tony" }
const nameFromEmp = getPropertyValue("name",employee);
const nameFromStudent = getPropertyValue("name",student);
console.log(NAME OF STUDENT IS : ${nameFromStudent})
console.log(NAME OF EMP IS : ${nameFromEmp})
Very helpful. The way you explained everything is awesome.
Good to know! Btw, i wonder is there a theme for vs code, similar to what u've used coding javascript examples here. I love it.
Destructuring is so good!
Helpful content Tapas. Yes Object destructuring can save us a lot of time.
Thanks for sharing ๐
PS : Cover image is looking super cool.
Emilla Filipowicz
CEO
Hi, l've got some exciting news for you, l can teach you how you can turn your $150 into a whopping $4,600 in just 2 hours! Without interrupting your daily activities or sending money to anyone TEXT ME IF YOU ARE INTERESTED FOR MORE INFORMATION: ๐ WhatsApp No:+1 (209)-207-5967โฌ Text No:+1 (209)-207-5967