4 ms·
Haven't seen this mentioned, but here's one: const dog = { name: "Dog" } console.log(dog) VM287:1 {name: "Dog"} console.log({dog}) VM305:1 {dog: {…}}dog: {na
by pawelduda 5y ago
Haven't seen this mentioned, but here's one:
const dog = { name: "Dog" }
console.log(dog)
VM287:1 {name: "Dog"}
console.log({dog})
VM305:1 {dog: {…}}dog: {name: "Dog"}__proto__: Object
- ngcazz 5y agoWhat did you mean to emphasize here? Cos what I'm seeing is the language feature (ES6's "shorthand properties"), not something inherent to `console`.
- pawelduda 5y agoThe second example effectively prints an object with it's name. I often have multiple console.log statements and by utilizing that I know what each one is referring to just by typing 2 more characters. EDIT: perhaps a better description by someone else https://news.ycombinator.com/item?id=27524164 https://news.ycombinator.com/item?id=27524164