Posted By

bharmalammargmailcom on 11/17/11


Tagged

operator typeof


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

mmcachran


Using "typeof" operator in Javascript


 / Published in: JavaScript
 

  1. Object.toType = (function toType(global) {
  2. return function(obj) {
  3. if (obj === global) {
  4. return "global";
  5. }
  6. return ({}).toString.call(obj).match(/\s([a-z|A-Z]+)/)[1].toLowerCase();
  7. }
  8. })(this)

Report this snippet  

You need to login to post a comment.