new Object()
- Since:
-
- 1.0.0
Methods
-
<static> copyRawJSON(rawJSON)
-
Copies the raw JSON object by value (instead of copy by reference).
NOTE: Works on raw JSON objects alone.
Parameters:
Name Type Description rawJSONObject To be copied by value.
- Since:
-
- 1.0.0
Returns:
Newly copied by value object.
- Type
- Object
-
<static> freeze(obj [, deep])
-
Freezes the given object making it immutable. This operation is by default shallow and does not affect objects referenced by the given object.
Parameters:
Name Type Argument Default Description objObject The object to freeze.
deepBoolean <optional>
false Pass
trueto freeze sub-objects recursively.- Since:
-
- 1.0.0
Returns:
The given object
obj.- Type
- Object
-
<static> getKey(obj, value)
-
Returns the first matching key corresponding to the given value.
Example usage:
var obj1 = { "key1" : "value1", "key2" : "value2"}; var val1 = "value2"; var key = mindsmine.Object.getKey(obj1, val1); // key now contains the object: "key2"Parameters:
Name Type Description objObject The object from which to retrieve the key.
valueObject The value to find.
- Since:
-
- 1.0.0
Returns:
First matching key. If no matching value is found,
nullis returned.- Type
- Object | null
-
<static> getNullSafe(obj)
-
Returns a non-null object, even if the object being passed is a null object.
If the passed-in object is a non-null object, then it is returned as-is.
Example usage:
var obj1 = { "key1" : "value1", "key2" : "value2"}; var obj2 = null; var obj3 = mindsmine.Object.getNullSafe(obj1); var obj4 = mindsmine.Object.getNullSafe(obj2); // obj3 now contains the object: { "key1" : "value1", "key2" : "value2"} // obj4 now contains the object: {}Parameters:
Name Type Description objObject The object to safeguard against
null.- Since:
-
- 1.0.0
Returns:
If obj is
nullthen{}(empty object).- Type
- Object
-
<static> isPrimitive(value)
-
Returns
trueif the passed value is a JavaScript primitive object - a string, number or boolean.Parameters:
Name Type Description valueObject The value to test.
- Since:
-
- 1.0.0
Returns:
- Type
- Boolean