Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript object destructuring rename

// Renaming
// ----------------------------------------------
const { bar: foo } = { bar: 123 };
bar // Uncaught ReferenceError: bar is not defined
foo // 123


// Renaming with default value
// ----------------------------------------------
const { bar: foo = 123 } = { potato: 456 };
bar // Uncaught ReferenceError: bar is not defined
foo // 123
potato // Uncaught ReferenceError: potato is not defined
 
PREVIOUS NEXT
Tagged: #javascript #object #destructuring #rename
ADD COMMENT
Topic
Name
4+3 =