1. Falsy values
false — boolean false
0 — number zero
“” — empty string
null
undefined
NaN — Not A Number
2. Immutability conversion
mutable:
this.currentUser.classes.push(classId);
immutable:
this.currentUser = Object.assign({}, this.currentUser,
{classes: this.currentUser.classes.concat([classId])});
mutable:
user.classes = user.classes || [];
this.currentUser = user;
immutable:
this.currentUser = Object.assign({}, user,
{classes: user.classes || []});
No comments:
Post a Comment