Using "typeof" operator in Javascript


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.