
ES6
es6学习
sustyle
这个作者很懒,什么都没留下…
展开
-
js中splice方法和slice方法
slice(startIndex,endIndex):表示从起始startIndex截取endIndex(但不包含endIndex索引位置元素)之间的内容。splice方法用来操作数组splice(startIndex,deleteNum,item1,....,)连个参数都不传的情况,拷贝的是原数组的副本,对于数组对象来说是浅拷贝。startIndex和endIndex参数同时都传入的情况。第二个参数不为0,表示执行的是替换操作。第二个参数为0,表示执行的是插入操作。没有传第三个参数的情况下,原创 2023-03-02 11:51:50 · 832 阅读 · 0 评论 -
前端国际化如何对中文——>英文自动化翻译小demo
js文件中中文一键转换为英文。原创 2022-11-18 12:30:54 · 2101 阅读 · 0 评论 -
es6中的Class基本语法
直接上代码理解class Point {//constructor构造函数在new Point()时就会自动被调用 constructor(x, y) { this.x = x; this.y = y; }//方法的写法:1、前面不需要加上function这个关键字。//2、方法与方法之间不需要逗号分隔 toString() { return '(' + this.x + ', ' + this.y + ')'; }}const b = new Point翻译 2022-04-12 11:04:02 · 160 阅读 · 0 评论 -
es6中Generator函数的理解
Generator函数的定义形式上,Generator函数是一个普通函数,但是有两个特征。一是,function关键字与函数名之间有一个星号;二是,函数体内部使用yield表达式,定义不同的内部状态function* helloWorldGenerator() { yield 'hello'; yield 'world'; return 'ending';}var hw = helloWorldGenerator();Generator 函数的调用方法与普通函数一样,也是在函翻译 2022-04-11 16:41:25 · 937 阅读 · 1 评论 -
es6中数值和对象的扩展
es6中数值的扩展es6中对象的扩展翻译 2022-04-12 14:46:04 · 124 阅读 · 0 评论 -
es6中的Map和Set结构
Set 和 Map 结构也原生具有 Iterator 接口,可以直接使用for...of循环MapMap是一组键值对的结构,具有极快的查找速度与Map有关的方法的使用var m = new Map(); // 空Mapm.set('Adam', 67); // 添加新的key-valuem.set('Bob', 59);//遍历一下for (let pair of map) { console.log(pair);}//输出//[''Adam',67]//['Bob',59]翻译 2022-04-11 11:01:39 · 165 阅读 · 0 评论 -
ES6 Module中的export 和import
本文是看《Webpack实战:入门、进阶与调优》这本书之后的感想和总结。ES6 Module中使用export 来导出模块,export有两种形式:命名导出默认导出1、命名导出的export和importexport一个模块可以有多个命名导出,命名导出有两种不同的写法://写法1,变量的声明和导出写在一行export const name = "xiaosun";export const add = function (a,b){ return a + b; }//写法2,变量先声翻译 2022-04-09 16:41:02 · 511 阅读 · 0 评论