51L3N7

RAR: typeof

Feb 16th, 2014
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Simulate "typeof" statement
  3.  *
  4.  * @author Roger Lima ([email protected])
  5.  * @date 16/fev/2014
  6.  * @update 22/feb/2016
  7.  *
  8.  * @param {Mixed} data
  9.  * @return {string|undefined}
  10.  */
  11. /* jshint laxbreak: true */
  12.  
  13. function type_of( data ) {
  14.     'use strict';
  15.  
  16.     return ( ( data instanceof Object && !( data instanceof Function ) ) || data === null )
  17.         ? 'Object'
  18.         : ( data !== undefined && data.constructor && data.constructor.name ) || undefined;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment