当前位置:网站首页>Object.prototype. Hasownproperty() and in
Object.prototype. Hasownproperty() and in
2022-07-25 15:12:00 【Deep sea blue mountains】
hasOwnProperty() All inherited Object All of the objects will inherit to hasOwnProperty Method . This method can be used to detect whether an object contains specific attributes of itself ; and in Operators are different , This method ignores the properties inherited from the prototype chain .
in The operator : Detect specified objects ( On the right ) Whether there is a corresponding attribute value on the prototype chain .
hasOwnProperty Method : Detect whether there is a corresponding attribute value on the specified object .
The difference between the two is in Will find the prototype chain , and hasOwnProperty Can't hasOwnProperty() grammar
obj.hasOwnProperty(prop) Parameters :prop Of the attribute to be detected String Name in string form , perhaps Symbol.
Return value : Boolean value used to determine whether an object contains a specified attribute Boolean. This method Can't Check whether the attribute exists in the prototype chain of the object , This attribute is only an object In itself Only one member of will return true
Example
Object.prototype.bar = {bar:'object prototype'};
var foo = {
goo: undefined
};
console.log('bar' in foo);// expected output: true(in Will find the prototype chain )
console.log(foo.hasOwnProperty('bar'));// expected output: false
console.log(foo.hasOwnProperty('goo'));// expected output: true
边栏推荐
- Sublimetext-win10 cursor following problem
- MeanShift聚类-01原理分析
- iframe嵌套其它网站页面 全屏设置
- Scala111-map、flatten、flatMap
- How to realize a correct double check locking
- Deployment and simple use of PostgreSQL learning
- Log4j2 basic configuration
- 记一次redis超时
- "Ask every day" what is volatile
- Leo-sam: tightly coupled laser inertial odometer with smoothing and mapping
猜你喜欢

Spark AQE

记一次Spark foreachPartition导致OOM

Pl/sql creates and executes ORALCE stored procedures and returns the result set

如何解决Visual Stuido2019 30天体验期过后的登陆问题

MySql的安装配置超详细教程与简单的建库建表方法

Fast-lio: fast and robust laser inertial odometer based on tightly coupled IEKF

Share a department design method that avoids recursion

Recommend 10 learning websites that can be called artifact

Vs2010添加wap移动窗体模板

Introduction to raspberry Pie: initial settings of raspberry pie
随机推荐
Use the command to check the WiFi connection password under win10 system
oracle_ 12505 error resolution
outline和box-shadow实现外轮廓圆角高光效果
Detailed explanation of lio-sam operation process and code
Scala111-map、flatten、flatMap
RedisCluster搭建和扩容
What is the Internet of things
[Nacos] what does nacosclient do during service registration
记一次Spark foreachPartition导致OOM
vscode 插件篇收集
"How to use" observer mode
Handle Oracle deadlock
Spark获取DataFrame中列的方式--col,$,column,apply
CGO is realy Cool!
一个程序最多可以使用多少内存?
C, c/s upgrade update
"Ask every day" how locksupport realizes thread waiting and wakeup
[C题目]力扣876. 链表的中间结点
oracle_12505错误解决方法
Sublimetext-win10 cursor following problem