当前位置:网站首页>Arguments class array in JS
Arguments class array in JS
2022-07-27 05:41:00 【weixin_ forty-six million fifty-one thousand two hundred and si】
An array of class , Similar to arrays , But there are no common methods and properties of arrays
How to traverse the class array ?
- Apply array methods to class arrays , Use call and apply, Use forEach
function fun(){
Array.prototype.forEach.call(arguments,(items)=>{
console.log(item);
})
}
- Convert a class array to an array , Use Array.from(), For an array of classes , Create a new array instance
function fun(){
const arr=Array.from(arguments)
console.log(item);
}
- Use the expansion operator to convert the class array into an array
function fun(){
const arr=[...arguments]
console.log(arr1);
arr.forEach((item)=>{
console.log(item);
})
}
边栏推荐
猜你喜欢
随机推荐
while循环
维持登录,路由跳转
C language elementary level -- branch statement (if, switch)
JS中是如何使用for..of来遍历对象
beef-xss安装与使用
正则表达式
C语言初阶——分支语句(if,switch)
First knowledge of C language -- common data types
Sharing force buckle-189. Three solutions of rotation array
Program environment and preprocessing (Part 1): how does a program run successfully?
初识C语言——为什么每个C程序都有一个main函数
XSS知识点
「PHP基础知识」使用echo语句输出信息
[MRCTF2020]Ezpop 1
程序环境和预处理(上):一个程序是怎么成功运行的?
Ubuntu:安装PostgreSQL
C语言字符串介绍以及相关操作函数
C language makes a small maze
Think about the role of some documents
攻防世界-mfw









