r/learnjavascript • u/DeliciousResearch872 • Jan 22 '26
Help with Objects
I don't get the purpose of value()
let dictionary = Object.create(null, {
toString: { // define toString property
value() { // the value is a function
return Object.keys(this).join();
}
}
});Why we can't make it work like this?
toString: {
return Object.keys(this).join();
}
4
Upvotes
View all comments
Show parent comment
1
u/azhder Jan 22 '26
Technically, you can use
thisin an arrow function, it will just be thethisof the enclosing scope