Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

javascript destructure object and rename

const o = {p: 42, q: true};
const {p: foo, q: bar} = o;

console.log(foo); // 42
console.log(bar); // true
Comment

js deconstruct rename

const { twitter: tweet, facebook: fb } = wes.links.social;
Comment

PREVIOUS NEXT
Code Example
Javascript :: json example 
Javascript :: angular pipe to capitalize first letter 
Javascript :: puppeteer mac m1 
Javascript :: add item to array in javascript 
Javascript :: js Write a function that will return a random integer between 10 and 100 
Javascript :: express middleware logging 
Javascript :: react array.map with return 
Javascript :: saving text in javascript 
Javascript :: javascript reduce 
Javascript :: refresh page by hand in react 
Javascript :: for each of object 
Javascript :: react hook form reset 
Javascript :: js create object from array 
Javascript :: simple kick command discord.js v12 
Javascript :: jq examples 
Javascript :: initialize express app 
Javascript :: js add key to object 
Javascript :: js custom event 
Javascript :: react native images 
Javascript :: add new items in a select input using js 
Javascript :: javascript get multiple elements by id 
Javascript :: varchar max length 
Javascript :: how to set env variables in js 
Javascript :: node js get list of all names of object array 
Javascript :: javascript check type of object 
Javascript :: concat js mdn 
Javascript :: nodejs emit event from class 
Javascript :: textalignvertical not working in ios react native 
Javascript :: fetch api in js 
Javascript :: image upload react 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =