types

Wsh.Util. types

Source:

Methods

(static) isDate(val) → {boolean}

Source:

Checks if a value is classified as a Date object.

Example
var isDate = Wsh.Util.types.isDate; // Shorthand

isDate(new Date()); // true
isDate(undefined); // false
Parameters:
Name Type Description
val any

The value to check.

Returns:
  • Returns true if the value is a Date, else false.
Type
boolean

(static) isRegExp(val) → {boolean}

Source:

Checks if a value is classified as an RegExp object.

Example
var isRegExp = Wsh.Util.types.isRegExp; // Shorthand

isRegExp(new RegExp('\\.js$')); // true
isRegExp(undefined); // false
Parameters:
Name Type Description
val any

The value to check.

Returns:
  • Returns true if the value is an RegExp, else false.
Type
boolean

(static) protoTypeOf() → {string}

Source:

Returns an Object.prototype of a value.

Example
var protoTypeOf = Wsh.Util.types.protoTypeOf; // Shorthand

console.log(typeof null); // object
console.log(protoTypeOf(null)); // null

console.log(typeof [1, 2, 3]); // object
console.log(protoTypeOf([1, 2, 3])); // Array

console.log(typeof new Date()); // object
console.log(protoTypeOf(new Date())); // Date

console.log(typeof /^regexp$/i); // object
console.log(protoTypeOf(/^regexp$/i)); // RegExp
Returns:
Type
string