Related methods of JS

1. The difference between assign and merge methods

The first parameter of the object.assign method is the target object, and the following parameters are all source objects.

If the target object has an attribute with the same name as the source object, or if multiple source objects have attributes with the same name, the later attributes will override the earlier ones.

merge is also similar to assign, the difference is that when merge encounters the same attribute, if the attribute value is a plain object (plain object) or a collection (collection), instead of overwriting the previous attribute value with the latter attribute value, it It will merge the two attribute values ​​before and after .

2. The difference between undefined and null and empty string

The _.has() method is used to check if the path is a direct property of the object. Returns true if the path exists, false otherwise.

The _.isNull() method is used to find out if the value of an object is null. Returns true if the value is null, false otherwise.

3. Base herf attribute

Add the address pointed to by the base link before the file of the relative path

4. Null coalescing operator ( ?? )

When the left operand is  null  or  undefined  , return the right operand , otherwise return the left operand .

Guess you like

Origin blog.csdn.net/Anna_lhy/article/details/131722971