{
//有默认值的后面如果有参数必须要有默认值
function test(x,y="world"){
console.log(x,y)
}
test('hello');//hello world
test('hello',"kill");//hello kill }
{
let x='test';
function test2(x,y=x){
console.log('作用域',x,y);
}
test2('kill');//kill kill
function test3(c,y=x){
console.log('作用域',c,y);
}
test3('kill');//kill test
}
{
//如果参数是arg,不可以有其他参数
function test3(...arg){
for(let v of arg){
console.log('rest',v);
}
}
test3(1,2,3,4,'a');
}
{
console.log(...[1,2,4]);//1 2 4
console.log('a',...[1,2,4]);//a 1 2 4
}
//箭头函数
{
// 函数名 参数 返回值
let arrow = v => v*2;
console.log(arrow(3));// let arrow2=()=>5;
console.log(arrow2())
}

es6基础(7)--函数扩展的更多相关文章

  1. ES6学习之函数扩展

    函数默认参数 function test(x = 1, y = 2) { return x + y } test(5, 6) test() 若默认参数在必须参数之前,要想取得默认参数,只有当传入的值为 ...

  2. es6 语法 (函数扩展)

    //函数参数默认值(more值后不能有参数) { function test(x,y = 'world'){ console.log('默认值',x,y); } test('hello');// he ...

  3. es6基础(3)-正则扩展

    //正则扩展 { let regex=new RegExp('xyz','i'); let regex2=new RegExp(/xyz/i); console.log(regex.test('xyz ...

  4. 【ES6基础】字符串扩展

    4.字符串扩展 (1)for...of循环遍历. let foo = [1,2,3,4,5,6] for(let i of foo){ console.log(i); } 结果: (2)include ...

  5. es6基础(6)--数组扩展

    //数组扩展 { let arr=Array.of(3,4,6,7,9,11);//可以是空 console.log('arr=',arr);//[3,4,6,7,9,11] } { //Array. ...

  6. es6基础(4)--字符串扩展

    //字符串扩展 { console.log('a','\u0061'); console.log('s','\u20BB7');//超过了0xffff console.log('s','\u{20BB ...

  7. es6基础(5)--数值扩展

    { //Number.isFinite数字是有尽的 console.log(Number.isFinite(15));//true console.log(Number.isFinite(NaN)); ...

  8. 深入理解javascript函数系列第四篇——ES6函数扩展

    × 目录 [1]参数默认值 [2]rest参数 [3]扩展运算符[4]箭头函数 前面的话 ES6标准关于函数扩展部分,主要涉及以下四个方面:参数默认值.rest参数.扩展运算符和箭头函数 参数默认值 ...

  9. ES6函数扩展

    前面的话 函数是所有编程语言的重要组成部分,在ES6出现前,JS的函数语法一直没有太大的变化,从而遗留了很多问题和的做法,导致实现一些基本的功能经常要编写很多代码.ES6大力度地更新了函数特性,在ES ...

随机推荐

  1. redis 学习资料

    redis 学习资料 网址 Redis 教程(菜鸟教程) http://www.runoob.com/redis/redis-tutorial.html Redis 命令参考 http://redis ...

  2. 快速学习hadoop只有这些基础可不行

    “学习hadoop需要什么基础”这已经不是一个新鲜的话题了,随便上网搜索一下就能找出成百上千篇的文章在讲学习hadoop需要掌握的基础.再直接的一点的问题就是——学Hadoop难吗?用一句特别让人无语 ...

  3. c#:$用法

    为什么会出现$符号,c#6.0才出现的新特性 var s = string.Fromat("{0}+{1}={2}",12,23,12+23) 用起来必须输入string.From ...

  4. Python3.6+Scrapy爬取知名技术文章网站

    爬取分析 伯乐在线已经提供了所有文章的接口,还有下一页的接口,所有我们可以直接爬取一页,再翻页爬. 环境搭建 Windows下安装Python: http://www.cnblogs.com/0bug ...

  5. String[]字符串数组,按字典顺序排列大小

    package ltb6w1; public class WordSort1 { private String[] a= {"hello","world",&q ...

  6. Reg2Bat_By Slore(生成同名bat文件,支持XP WIN7 WIN7X64).vbs

    原文http://slore.blogbus.com/logs/52627038.htmlSlore编写的这个reg文件转换为bat文件,是逐句转换的,不是通过批处理生成临时reg文件然后导入的方法, ...

  7. 统计apk或jar中方法数量

    一.apk中方法数量 ./android-sdk-linux/build-tools/23.0.2/dexdump -f  apk路径 | grep method_ids_size 二.jar中方法数 ...

  8. 【JVM参数】Java启动时,显示class是从哪个Jar中加载的

    显示具体的Class是从哪个Jar文件加载 JVM参数: -verbose:class 启动后输出如下: [Opened D:\Program Files\Java\jdk1.8.0_131\jre\ ...

  9. uoj #14.【UER #1】DZY Loves Graph

    http://uoj.ac/problem/14 由于加入的边权递增,可以直接运行kruskal并支持撤销,但这样如果反复批量删边和撤销,时间复杂度会退化,因此需要对删边操作加上延时处理,只有在删边后 ...

  10. Kubernetes查看日志命令

    查看pod日志 kubectl logs <pod_name> kubectl logs <pod_name> -c <container_name> docker ...