[英]How does this Javascript one-liner function work?
var hasAll = Object.keys(obj1).every(Object.prototype.hasOwnProperty.bind(obj2));
我采取的这段代码是从解决方案到最佳方法来检查一个JavaScript对象是否具有另一个JavaScript对象的所有键的。
It borrows Object#hasOwnProperty
from the prototype of Object
and uses bj2
as this
object with binding ( Function#bind
). 它借用
Object#hasOwnProperty
从原型Object
,并使用bj2
作为this
目的用结合( Function#bind
)。
The result is a function, which can be used as callback. 结果是一个函数,可以用作回调。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.