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

PREVIOUS NEXT
Code Example
Javascript :: copy dict js 
Javascript :: splidejs autoscroll pauseOnHover 
Javascript :: types of node in blockchain 
Javascript :: jquery ajax form submission 
Javascript :: timestamps in mongoose 
Javascript :: javascript get distinct values from array 
Javascript :: Add event listener for loop 
Javascript :: javascript seconds to date 
Javascript :: javascript every other element in array 
Javascript :: You need to authorize this machine using `npm adduser` 
Javascript :: javascript settimeout loop 
Javascript :: javascript loop over object entries 
Javascript :: how to convert array to uppercase in javascript 
Javascript :: settime out with promise 
Javascript :: react native scaling font 
Javascript :: javascript find a digit in str 
Javascript :: node get root directory 
Javascript :: jquery keep scroll position 
Javascript :: js get date in ms 
Javascript :: jquery get all checkbox checked 
Javascript :: socket io client 
Javascript :: could not resolve module fs react native 
Javascript :: check if string matches regex js 
Javascript :: regex contains string in end 
Javascript :: postman test check response status 
Javascript :: remove key from object array javascript 
Javascript :: js inline if 
Javascript :: if jsp 
Javascript :: vscode js brackets not close 
Javascript :: How to get tailwindcss intellisense to work with react files 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =