Guest User

Untitled

a guest
Mar 24th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. var toString = Object.prototype.toString;
  2. var strLit = 'example';
  3. var strStr = String('example')​;
  4. var strObj = new String('example');
  5.  
  6. console.log(typeof strLit); // string
  7. console.log(typeof strStr); // string
  8. console.log(typeof strObj); // object
  9.  
  10. console.log(strLit instanceof String); // false
  11. console.log(strStr instanceof String); // false
  12. console.log(strObj instanceof String); // true
  13.  
  14. console.log(toString.call(strLit)); // [object String]
  15. console.log(toString.call(strStr)); // [object String]
  16. console.log(toString.call(strObj)); // [object String]
Add Comment
Please, Sign In to add comment