You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 09-Data-Structure-Modern-Operators-and-Strings/README.md
+44
Original file line number
Diff line number
Diff line change
@@ -221,3 +221,47 @@ for (const bar of newMenu2.entries()) {
221
221
222
222
console.log([...newMenu2.entries()]);
223
223
```
224
+
225
+
# Enhanced Object Literals
226
+
227
+
Object literals are objects written literally, using the curly braces syntax. With ES6, enhanced object literals introduced three ways that allows you write object literals in an easy way.
228
+
229
+
It provides a shorthand syntax for initializing properties from variables.
230
+
It provides a shorthand syntax for defining function methods.
231
+
It enables the ability to have computed property names in an object literal definition
232
+
233
+
For Example.
234
+
Consider the object below which has two methods and nested objects. With enhanced object literal, we don't need to assign a key: and it's value pair, we simply just write the object name.
Here we removed the colon `:` and the property `name` and simply passed in the object as a variable, and wrote the function like a regular function without the function keyword and colon.
266
+
267
+
These all balls down to personal preference. You can choose which one you want to use.
0 commit comments