JavaScript checks the type of object

From , 5 Years ago, written in JavaScript, viewed 130 times.
URL https://pastebin.vip/view/6e3b0bf8
  1. function is(type, obj) {
  2.     var clas = Object.prototype.toString.call(obj).slice(8, -1);
  3.     return obj !== undefined && obj !== null && clas === type;
  4. }
  5.  
  6. is('String', 'test'); // true
  7. is('String', new String('test')); // true
  8. //javascript/4801

Reply to "JavaScript checks the type of object"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website