DevScrolls
59 subscribers
2 photos
8 files
86 links
A thoughtful builder's journal — exploring modern frontend architecture, state management, design systems, and the craft of resilient software.

For more:

https://www.devscrolls.dev
Download Telegram
97. What's the output?

const info = { [Symbol('a')]: 'b', }; console.log(info); console.log(Object.keys(info));
Anonymous Poll
39%
A: {Symbol('a'): 'b'} and ["{Symbol('a')"]
39%
B: {} and []
6%
C: { a: "b" } and ["a"]
17%
D: {Symbol('a'): 'b'} and []
DevScrolls
97. What's the output?

const info = { [Symbol('a')]: 'b', }; console.log(info); console.log(Object.keys(info));
Answer: D
A Symbol is not enumerable. The Object.keys method returns all enumerable key properties on an object. The Symbol won't be visible, and an empty array is returned. When logging the entire object, all properties will be visible, even non-enumerable ones.
This is one of the many qualities of a symbol: besides representing an entirely unique value (which prevents accidental name collision on objects, for example when working with 2 libraries that want to add properties to the same object), you can also "hide" properties on objects this way (although not entirely. You can still access symbols using the Object.getOwnPropertySymbols() method).
98. What's the output?

const getList = ([x, ...y]) => [x, y]

const getUser = user => { name: user.name, age: user.age }

const list = [1, 2, 3, 4]
const user = { name: "Lydia", age: 21 }

console.log(getList(list)) console.log(getUser(user))
Hey folks from now on you’ll receive frontend related update and new tips and tricks for your development
Hey folks I have create our the daily frontend community on LinkedIn when I can post articles, share my thoughts and also every day polls… pls join there together we learn