Created
April 3, 2022 11:28
-
-
Save gilles-gardet/62bfd6b14b4910a5db573de9f420845d to your computer and use it in GitHub Desktop.
Revisions
-
gilles-gardet created this gist
Apr 3, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ // we can also give alias name of variable when destructuring const productData = {id: 23, name: 'Laptop'} const {name: deviceName} = productData console.log('deviceName', deviceName) // deviceName Laptop // here destructuring value with dynamic key const extractKey = 'name' const { [extractKey]: data } = productData console.log('data', data) // data Laptop