我是靠谱客的博主 安详发卡,这篇文章主要介绍instanceof与typeof,现在分享给大家,希望可以做个参考。

都会返回类型信息,但installedof与内存中的比较typeof与字符串比较

//objects
  var Person = function() {}

  var gary = new Person();

  console.log(typeof(gary)); // "object"
  gary instanceof Person // true

  //literals
  var str = 'hello world';
  console.log(typeof(str)); // "string"
  str instanceof String // False

  var str1 = new String('hello world');
  console.log(typeof(str1)) // "object"
  str1 instanceof String // true 

  

转载于:https://www.cnblogs.com/xiaqi/p/4545417.html

最后

以上就是安详发卡最近收集整理的关于instanceof与typeof的全部内容,更多相关instanceof与typeof内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(52)

评论列表共有 0 条评论

立即
投稿
返回
顶部