当前位置:网站首页>for in 与Object.keys()的区别
for in 与Object.keys()的区别
2022-06-12 11:59:00 【mustang(野马)】
for in 与Object.keys()的区别
function Person(name, age) {
this.name = name;
this.age = age;
}
Person.prototype = {
sex: "男"
}
var man = new Person("张三", 18);
console.log(Object.keys(man));//["name","age"]
for (var key in man) {
console.log(key);//name age sex
}
总结:
// Object.keys():返回一个数组,数组值为对象自有的属性,不会包括继承原型的属性
//
// for in :遍历对象可枚举属性,包括自身属性,以及继承自原型的属性
边栏推荐
- Lambda and filter, index of list and numpy array, as well as various distance metrics, concatenated array and distinction between axis=0 and axis=1
- 机器学习之线性模型
- System. IO. Fileloadexception exception
- 無重複字符的最長字符串(LeetCode 3)
- 单元测试用例框架--unittest
- Reprint --win10 open the task manager to solve the blue screen problem
- Video JS library uses custom components
- Neighbor item status update of neighbor subsystem
- 一个人必须不停地写作,才能不被茫茫人海淹没。
- Node crawler puppeter usage
猜你喜欢

JS to load and display Excel files

QT添加QObject类(想使用信号和槽)遇到的问题汇总,亲测解决有效error: undefined reference to `vtable for xxxxxx(你的类名)‘

First understand the onion model, analyze the implementation process of middleware, and analyze the source code of KOA Middleware

Compiling Draco library on Windows platform

ARM processor mode and register

Blue Bridge Cup 2015 CA provincial competition (filling the pit)

TinyMCE realizes automatic uploading of pasted pictures

转载--win10打开任务管理器就蓝屏的问题

Inter class and intra class relations in video classification -- regularization
![[foundation of deep learning] learning of neural network (4)](/img/8d/0e1b5d449afa583a52857b9ec7af40.png)
[foundation of deep learning] learning of neural network (4)
随机推荐
TinyMCE series (III) introduction to common TinyMCE APIs
ARM指令集之Load/Store指令寻址方式(一)
A.前缀极差
M-arch (fanwai 10) gd32l233 evaluation -spi drive DS1302
B.刷墙(C语言)
7-5 复数四则运算
创建Servlet项目
IP address management
Design of TTable
机器学习之线性模型
Getting started with NVIDIA Jetson nano Developer Kit
无重复字符的最长字符串(LeetCode 3)
LeetCode 497. 非重叠矩形中的随机点(前缀和+二分)
VirtualBox virtual machine shut down due to abnormal system. The virtual machine startup item is missing
转载--win10打开任务管理器就蓝屏的问题
判断网络文件是否存在,获取网络文件大小,创建时间、修改时间
LeetCode 1037. 有效的回旋镖(向量叉乘)
文件夹目录结构自动生成
异步路径处理
标品和非标品如何选品,选品的重要性,店铺怎样布局