-
Notifications
You must be signed in to change notification settings - Fork 24
General Purpose Functions
Performs a deep clone of an object, returning a reference to the clone
var o = {
foo:'bar',
bar: {
array: [0, 1, 2, 3, 4]
}
};
var clone = Scule.global.functions.cloneObject(o);
Returns the length (number of keys/elements) of the provided object as an integer value. This function supports Objects, Strings, and Arrays as valid arguments.
var string = 'abcdefg';
var array = [0, 1, 2, 3, 4];
var object = {a:1, b:2, c:3, d:4};
Scule.global.functions.sizeOf(string); // 7
Scule.global.functions.sizeOf(array); // 5
Scule.global.functions.sizeOf(object); // 4
Shuffles the provided array in place - this function does not preserve keys in associative arrays.
var a = [0, 1, 2, 3, 4, 5];
Scule.global.functions.shuffle(a); // value of a is now [4, 2, 0, 1, 3, 5] - or some other random order
Returns a boolean value indicating whether or not the provided object is an instance of the Array class.
Returns a boolean value indicating whether or not the provided object is an integer.
Returns a boolean value indicating whether or not the provided object is a floating point number.
Returns a boolean value indicating whether or not the provided value is scalar.
Returns a random integer between the two provided range bounds.
var random = Scule.global.functions.randomFromTo(1, 10);