console.log({ a, b })
where a and b are some variables. This will print the name of the variable next to its value. So it can be thought as a faster version of
console.log('a: ' + a)
console.log({ a: a, b: b })
What I do is console.log('MyVariable',MyVariable,'MyOtherVariable',MyOtherVariable);
When writing it I simply copy the variable, "paste twice" and then "wrap with quotation marks".
That one is pretty nice because you can add ,'\n' to have a new line. console.log('MyVariable',MyVariable,'\n','MyOtherVariable',MyOtherVariable);
const { some: { nested: { field } } } = tree; // field === tree.some.nested.field
or rename things while you destructure them:
const { crappyFieldName: betterName } = myObject; // betterName === myObject.crappyFieldName
Now I can't stop using this feature...
console.log({ a, b })
where a and b are some variables. This will print the name of the variable next to its value. So it can be thought as a faster version of
console.log('a: ' + a)