JS Object, This, & JSON Flashcards
Can a property be deleted from an object?
There isn’t any method in an Object itself to delete its own properties (such as Map.prototype.delete()). To do so, one must use the delete operator.
(Map is preferable if deletion is necessary)
Object.assign()
Copies the values of all enumerable own properties from one or more source objects to a target object.
Object.create()
Creates a new object with the specified prototype object and properties.
Object.defineProperty()
Object.defineProperties()
Adds the named properties described by the given descriptors to an object.
Object.entries()
Object.fromEntries()
Returns an array containing all of the [key, value] pairs of a given object’s own enumerable string properties.
and the reverse, returns a new object from an iterable of [key, value] pairs.
Object.freeze()
Object.isFrozen()
Freezes an object. Other code cannot delete or change its properties.
Determines if an object was frozen.
Object.is()
Compares if two values are the same value. Equates all NaN values (which differs from both IsLooselyEqual used by == and IsStrictlyEqual used by ===).
Object.keys()
Object.values()
Returns an array containing the names of all of the given object’s own enumerable string properties.
Returns an array containing the values that correspond to all of a given object’s own enumerable string properties.
Object.isSealed()
Object.seal()
Determines if an object is sealed.
Prevents other code from deleting properties of an object.
Object.preventExtensions()
Object.isExtensible()
Prevents any extensions of an object.
Determines if extending of an object is allowed.
Object.prototype.toLocaleString()
Calls toString().
Object.prototype.toString()
Returns a string representation of the object.
Object.prototype.valueOf()
Returns the primitive value of the specified object.
JSON
The JSON object contains methods for parsing JavaScript Object Notation (JSON) and converting values to JSON.
JavaScript and JSON differences
JSON is a syntax for serializing objects, arrays, numbers, strings, booleans, and null. It is based upon JavaScript syntax but is distinct from it: some JavaScript is not JSON.
Objects and Arrays
for JSON: property names must be double-quoted strings; trailing commas are forbidden.
Numbers
Leading zeros are prohibited. A decimal point must be followed by at least one digit. NaN and Infinity are unsupported.