Methods
-
<static> array( value ) → {boolean}
Checks if the
valueis an array. -
Parameters
Name Type Description value* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is; console.log( _is.array( [] ) ); // => true console.log( _is.array( null ) ); // => false console.log( _is.array( 123 ) ); // => false console.log( _is.array( "" ) ); // => falseDetails
-
<static> boolean( value ) → {boolean}
Checks if the
valueis a boolean. -
Parameters
Name Type Description value* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is; console.log( _is.boolean( true ) ); // => true console.log( _is.boolean( false ) ); // => true console.log( _is.boolean( "true" ) ); // => false console.log( _is.boolean( "false" ) ); // => false console.log( _is.boolean( 1 ) ); // => false console.log( _is.boolean( 0 ) ); // => falseDetails
-
<static> element( value ) → {boolean}
Checks if the
valueis an element. -
Parameters
Name Type Description value* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is, // create an element to test el = document.createElement("span"); console.log( _is.element( el ) ); // => true console.log( _is.element( $(el) ) ); // => false console.log( _is.element( null ) ); // => false console.log( _is.element( {} ) ); // => falseDetails
-
<static> empty( value ) → {boolean}
Checks if the
valueis empty. -
Description
The following values are considered to be empty by this method:
""- An empty string0- 0 as an integer0.0- 0 as a float[]- An empty array{}- An empty object$()- An empty jQuery objectfalsenullundefined
Parameters
Name Type Description value* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is; console.log( _is.empty( undefined ) ); // => true console.log( _is.empty( null ) ); // => true console.log( _is.empty( 0 ) ); // => true console.log( _is.empty( 0.0 ) ); // => true console.log( _is.empty( "" ) ); // => true console.log( _is.empty( [] ) ); // => true console.log( _is.empty( {} ) ); // => true console.log( _is.empty( 1 ) ); // => false console.log( _is.empty( 0.1 ) ); // => false console.log( _is.empty( "one" ) ); // => false console.log( _is.empty( ["one"] ) ); // => false console.log( _is.empty( { "name": "My Object" } ) ); // => falseDetails
-
<static> error( value ) → {boolean}
Checks if the
valueis an error. -
Parameters
Name Type Description value* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is, // create some errors to test err1 = new Error("err1"), err2 = new SyntaxError("err2"); console.log( _is.error( err1 ) ); // => true console.log( _is.error( err2 ) ); // => true console.log( _is.error( null ) ); // => false console.log( _is.error( 123 ) ); // => false console.log( _is.error( "" ) ); // => false console.log( _is.error( {} ) ); // => false console.log( _is.error( [] ) ); // => falseDetails
-
<static> fn( value ) → {boolean}
Checks if the
valueis a function. -
Parameters
Name Type Description value* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is, // create a function to test func = function(){}; console.log( _is.fn( func ) ); // => true console.log( _is.fn( null ) ); // => false console.log( _is.fn( 123 ) ); // => false console.log( _is.fn( "" ) ); // => falseDetails
-
<static> hash( value ) → {boolean}
Checks if the
valueis a hash. -
Parameters
Name Type Description value* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is; console.log( _is.hash( {"some": "prop"} ) ); // => true console.log( _is.hash( {} ) ); // => true console.log( _is.hash( window ) ); // => false console.log( _is.hash( document ) ); // => false console.log( _is.hash( "" ) ); // => false console.log( _is.hash( 123 ) ); // => falseDetails
-
<static> jq( value ) → {boolean}
Checks if the
valueis a jQuery object. -
Parameters
Name Type Description value* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is, // create an element to test el = document.createElement("span"); console.log( _is.jq( $(el) ) ); // => true console.log( _is.jq( $() ) ); // => true console.log( _is.jq( el ) ); // => false console.log( _is.jq( {} ) ); // => false console.log( _is.jq( null ) ); // => false console.log( _is.jq( 123 ) ); // => false console.log( _is.jq( "" ) ); // => falseDetails
-
<static> number( value ) → {boolean}
Checks if the
valueis a number. -
Parameters
Name Type Description value* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is; console.log( _is.number( 123 ) ); // => true console.log( _is.number( undefined ) ); // => false console.log( _is.number( null ) ); // => false console.log( _is.number( "" ) ); // => falseDetails
-
<static> object( value ) → {boolean}
Checks if the
valueis an object. -
Parameters
Name Type Description value* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is; console.log( _is.object( {"some": "prop"} ) ); // => true console.log( _is.object( {} ) ); // => true console.log( _is.object( window ) ); // => true console.log( _is.object( document ) ); // => true console.log( _is.object( undefined ) ); // => false console.log( _is.object( null ) ); // => false console.log( _is.object( "" ) ); // => false console.log( _is.object( 123 ) ); // => falseDetails
-
<static> promise( value ) → {boolean}
Checks if the
valueis a promise. -
Description
This is a simple check to determine if an object is a jQuery promise object. It simply checks the object has a
thenandpromisefunction defined.The promise object is created as an object literal inside of
jQuery.Deferred, it has no prototype, nor any other truly unique properties that could be used to distinguish it.This method should be a little more accurate than the internal jQuery one that simply checks for a
promisefunction.Parameters
Name Type Description value* The object to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is; console.log( _is.promise( $.Deferred() ) ); // => true console.log( _is.promise( {} ) ); // => false console.log( _is.promise( undefined ) ); // => false console.log( _is.promise( null ) ); // => false console.log( _is.promise( "" ) ); // => false console.log( _is.promise( 123 ) ); // => falseDetails
-
<static> size( value ) → {boolean}
Checks if the
valueis a valid CSS length. -
Parameters
Name Type Description value* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is; console.log( _is.size( 80 ) ); // => true console.log( _is.size( "80px" ) ); // => true console.log( _is.size( "80em" ) ); // => true console.log( _is.size( "80%" ) ); // => true console.log( _is.size( {} ) ); // => false console.log( _is.size( undefined ) ); // => false console.log( _is.size( null ) ); // => false console.log( _is.size( "" ) ); // => falseDetails
-
<static> string( value ) → {boolean}
Checks if the
valueis a string. -
Parameters
Name Type Description value* The value to check.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is; console.log( _is.string( "" ) ); // => true console.log( _is.string( undefined ) ); // => false console.log( _is.string( null ) ); // => false console.log( _is.string( 123 ) ); // => falseDetails
-
<static> undef( value ) → {boolean}
Checks if the
valueisundefined. -
Parameters
Name Type Description value* The value to check is undefined.
Returns
Examples
// alias the FooGallery.utils.is namespace var _is = FooGallery.utils.is; console.log( _is.undef( undefined ) ); // => true console.log( _is.undef( null ) ); // => false console.log( _is.undef( 123 ) ); // => false console.log( _is.undef( "" ) ); // => falseDetails