Expected property shorthand
115 dob: dob,
116 gender: gender,
117 age: age,
118 user_type: user_type,119 });
120 }
121
Expected property shorthand
114 email: email,
115 dob: dob,
116 gender: gender,
117 age: age,118 user_type: user_type,
119 });
120 }
Expected property shorthand
113 surname: surname,
114 email: email,
115 dob: dob,
116 gender: gender,117 age: age,
118 user_type: user_type,
119 });
Expected property shorthand
112 firstname: firstName,
113 surname: surname,
114 email: email,
115 dob: dob,116 gender: gender,
117 age: age,
118 user_type: user_type,
Expected property shorthand
111 set(ref(database, "users/" + userId), {
112 firstname: firstName,
113 surname: surname,
114 email: email,115 dob: dob,
116 gender: gender,
117 age: age,
Expected property shorthand
110 const user_type = userInfo["user-type"];
111 set(ref(database, "users/" + userId), {
112 firstname: firstName,
113 surname: surname,114 email: email,
115 dob: dob,
116 gender: gender,
Description
ECMAScript 6 provides a concise form for defining object literal methods and properties. This syntax can make defining complex object literals much cleaner.
Here are a few common examples using the ES5 syntax:
const x = 1, y = 2, z = 3;
// properties
const foo = {
x: x,
y: y,
z: z,
};
// methods
const foo = {
a: function() {},
b: function() {}
};
The ES6 equivalent syntax is::
// properties
const foo = {x, y, z};
// methods
const bar = {
a() { return 1 },
b() { return 2 }
};
NOTE: The shorthand properties are equivalent to function expressions.
Meaning that they do not bind their own this
inside their bodies.
It is still possible to access properties from the object inside a shorthand member function:
const object = {
x: 1,
getX() {
return this.x // valid
}
}
Bad Practice
const foo = {
bar: function () { return 1 }
};
Recommended
const foo = {
bar() { return 1 }
}