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 rawJSON
Object 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 obj
Object The object to freeze.
deep
Boolean <optional>
false Pass
true
to 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 obj
Object The object from which to retrieve the key.
value
Object The value to find.
- Since:
-
- 1.0.0
Returns:
First matching key. If no matching value is found,
null
is 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 obj
Object The object to safeguard against
null
.- Since:
-
- 1.0.0
Returns:
If obj is
null
then{}
(empty object).- Type
- Object
-
<static> isEmpty(obj)
-
Returns
true
if the passed value is an Empty JavaScript Object.Example usage:
mindsmine.Object.isEmpty(null) // false mindsmine.Object.isEmpty(undefined) // false mindsmine.Object.isEmpty(NaN) // false mindsmine.Object.isEmpty(100) // false mindsmine.Object.isEmpty("") // false mindsmine.Object.isEmpty("hello") // false mindsmine.Object.isEmpty(true) // false mindsmine.Object.isEmpty(function() {}) // false mindsmine.Object.isEmpty([]) // false mindsmine.Object.isEmpty({}) // true
Parameters:
Name Type Description obj
Object The object to test.
- Since:
-
- 3.0.0
Returns:
Whether or not the object is empty
- Type
- Boolean
-
<static> isPrimitive(value)
-
Returns
true
if the passed value is a JavaScript primitive object - a string, number or boolean.Parameters:
Name Type Description value
Object The value to test.
- Since:
-
- 1.0.0
Returns:
Whether or not the object is of primitive data type
- Type
- Boolean