当前位置:网站首页>js中类数组对象以及类数组转换的方法(ES6, ES5)
js中类数组对象以及类数组转换的方法(ES6, ES5)
2022-07-23 05:39:00 【Vivqst】
js中类数组对象以及类数组转换的方法(ES6, ES5)
类数组(Array-like)对象,通常我们可以把拥有一个length属性和非负整数属性的对象称为类数组对象
JavaScript 数组与一般对象的区别:
- 当有新元素添加到列表中时,自动更新 length 属性
- 设置 length 属性值为一个较小值会截断数组
- 从 Array.prototype 中继承一些有用的方法
- 类属性为「Array」
注:类数组对象的length不会自动更新
常见的类数组对象有:
- document.getElementsByClassName获取的nodeList
- 函数的arguments
// 定义一个类数组
var likeArray = {
0: 'name', 1: 'age', 2: 'sex', length:3}
// ES5
var arr = Array.prototype.slice.call(likeArray)
// ['name', 'age', 'sex']
// ES6
Array.from(likeArray)
边栏推荐
猜你喜欢

When using cache in sprintboot, the data cannot be loaded

【C语言】什么是函数?函数的分类和侧重(帮你快速分类和记忆函数)

gbk编解码器无法解码的问题,有可能出题出在文件名上

Pywinauto+某应用程序(学习至第9讲)--受阻

牛客刷题记录--Mysql

Master slave synchronization step read / write separation + self encountered error sharing

大厂面试机器学习算法(5)推荐系统算法
![[pytho-flask筆記5]藍圖簡單使用](/img/0a/00b259f42e2fa83d4871263cc5f184.png)
[pytho-flask筆記5]藍圖簡單使用

PyGame realizes the airplane war game

Install enterprise pycharm and Anaconda
随机推荐
【无标题】
Flask蓝图
First meet flask
[python flask notes 5] blueprint is easy to use
Web server failed to start. Port 8080 was already in use.
使用cmd安装pygame
【uiautomation】键指令大全(以及三种调用方式)+常用鼠标动作+SendKeys+Inspect学习
JDBC learning and simple encapsulation
使用pytorch实现基于VGG 19预训练模型的鲜花识别分类器,准确度达到97%
The super simple face recognition API can realize face recognition in just a few lines of code
大厂面试机器学习算法(5)推荐系统算法
字典创建与复制
[metric]使用Prometheus监控flink1.13org.apache.flink.metrics
wps中的word中公式复制完后是图片
牛客刷题记录--Mysql
Spark common interview questions sorting
[flink]flink on yarn之flink-conf最简单配置
大厂面试机器学习算法(6)时间序列分析
Federated primary keys and indexes
防止神经网络过拟合的五种方法