---
title: "Comment by Zeshan Merchant on \"JavaScript object destructuring usages you must know\" | Hashnode"
description: "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: 𝗛𝗮𝗻𝗱𝗹𝗲 𝗱𝘆𝗻"
url: "https://hashnode.com/posts/javascript-object-destructuring-usages-you-must-know/61e54dac8a425719c173606f/comment/65997a299bd412cbb4af653c"
---

[Discussion](https://hashnode.com/posts/javascript-object-destructuring-usages-you-must-know/61e54dac8a425719c173606f)

Comment [JavaScript object destructuring usages you must know](https://hashnode.com/posts/javascript-object-destructuring-usages-you-must-know/61e54dac8a425719c173606f)

[Zeshan Merchant](https://hashnode.com/@zeshan0603)

[Jan 6, 2024](https://hashnode.com/posts/javascript-object-destructuring-usages-you-must-know/61e54dac8a425719c173606f/comment/65997a299bd412cbb4af653c)

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}`)
