当前位置:网站首页>How JS determines whether an object belongs to a class
How JS determines whether an object belongs to a class
2022-07-27 05:41:00 【weixin_ forty-six million fifty-one thousand two hundred and si】
The class itself points to the constructor , The data type of a class is a function
- instanceOf: Judge the function of the constructor prototype Whether the attribute appears anywhere in the prototype chain of the object
function Person(name){
this.name=name
}
var obj=new Person(' Zhang San ')
var obj1={
}
console.log(obj instanceof Person);//true
console.log(obj1 instanceof Person);//false
- Of the properties of an object constructor To judge , Constructor pointing to the object
function Person(name) {
this.name = name
}
var obj = new Person(' Zhang San ')
console.log(obj.__proto__.constructor);
obj.__proto__.constructor=Array
console.log(obj.__proto__.constructor);
边栏推荐
猜你喜欢

C语言初阶——分支语句(if,switch)

First knowledge of C language - string + escape character + comment

SSTI 模板注入

块,行内块元素之间存在间隙

Elment UI usage

函数和箭头函数

攻防世界-mfw

一本通1353——表达式括号匹配(栈)

Program environment and preprocessing (Part 2): define, undef, command line compilation, conditional compilation, file inclusion (super full collation, recommended collection!!!

权限的配置,组件传值
随机推荐
First knowledge of C language -- what is C language
GalleryCMS下载安装与配置
Think about the role of some documents
JS中如何判断一个属性是属于实例对象还是继承于构造函数
XXE&XML 漏洞
[网鼎杯 2020 青龙组]AreUSerialz(BUUCTF)
每周学习总结
let、const、var之间的用法以及区别
「PHP基础知识」定界符的使用
C语言字符串介绍以及相关操作函数
背景图片相关应用-铺满,自适应
MD5 password encryption
C语言入门介绍
XSS知识点
「PHP基础知识」PHP中的注释
Native token generation encryption and decryption
C语言进制转换以及原补反码位运算介绍
Program environment and preprocessing (Part 2): define, undef, command line compilation, conditional compilation, file inclusion (super full collation, recommended collection!!!
Introduction of C language base conversion and original complement inverse code point operation
Hi3516dv300 environment setup