都会返回类型信息,但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内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复