当前位置:网站首页>ES6新特性未命名参数
ES6新特性未命名参数
2022-08-08 21:04:00 【驻风丶】
javascript并不限制传入参数的数量,在函数调用时,传入的实参个数超过形参的个数时,则超过的部分参数就称为了剩余参数
ES6中提供了一种更加便捷处语法:
function fun(a,...b){
[剩余参数用三个点接收,多余的参数则被放到数组b中]
}
function foo(a,b,...c){
// arguments接收所有传入的实参
console.log(arguments)//[1,2,3,4,5]
// ...剩余参数只接收剩余的形参
console.log(c);//[3,4,5]
}
foo(1,2,3,4,5);
注意:
1、函数最多只能有一个剩余参数,且该参数必须放置在所有形参的最后
2、虽然有剩余参数(接收实参个数超过形参个数部分),arguments(接收所有传入的实参)仍然存在
3、剩余参数是在 函数声明的时候 出现
边栏推荐
- Simple Swing interface notes
- Blazor PWA 单页应用身份认证机制示例
- 目标检测论文 Few-Shot Object Detection with Attention-RPN and Multi-Relation Detector
- 【线性代数04】投影矩阵P和标准正交矩阵Q
- 【Export PDF-Project Application】
- GeoServer introductory study: 07 - release a larger multi-tiered TIF map data
- 最简单的idea构建微服务模块
- [MEF] Chapter 04 MEF's Multi-Component Import (ImportMany) and Directory Services
- Flask 教程 第四章:数据库
- Flask 教程 第五章:用户登录
猜你喜欢
[highcharts application - double pie chart]
【项目经验】--环保项目
Flask 教程 第二章:模板
Flask 教程 第五章:用户登录
目标检测论文 Few-Shot Object Detection with Attention-RPN and Multi-Relation Detector
GeoServer introductory study: 07 - release a larger multi-tiered TIF map data
一下科技:未来短视频行业发展呈四大趋势
GeoServer入门学习:05-多层级MBTiles规范数据发布
GeoServer Getting Started Learning: 06-Publishing Multi-level TIF Map Data
推荐7款好用的Visual Studio扩展
随机推荐
mysql8设置远程连接
GeoServer入门学习:02-安装部署
【梦想的声音】
GeoServer introductory learning: 05-Multi-level MBTiles specification data release
磁控胶囊胃镜:具有良好耐受性的非侵入性胃镜检查
day12 Elasticserach
GeoServer introductory study: 07 - release a larger multi-tiered TIF map data
go实现快速排序
Iterative version of preorder traversal, inorder traversal, and postorder traversal of binary tree
Flask 教程 第一章:Hello, World!
fashion CNNs code
C#实现Everything——数据显示
[The browser opens the exported excel]
sudo控制用户权限实战操作
numpy
EasyExcel上传文件并使用Postman测试
【highcharts应用-双饼图】
window下socket(TCP)控制台程序
【idea_取消自动import .*】
【线性代数05】行列式的性质和应用