![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
es6
xuxu_qkz
每天就要学芝麻大小!!!
展开
-
ES6中的类(Class)的写法
1.传统ES5中的class用法//ES5的对应写法 (function(){ //定义类、构造函数 function User(name,age){ this.name=name; this.age=age; } //定义原型原创 2017-11-23 09:31:17 · 6697 阅读 · 0 评论 -
vue 组件传参func用法
vue 组件传参func用法使用场景:比如一个button组件里面有一个loading属性,在父组件中如何去改变loading的值,一种是通过props去改变,另外一种可以通过func暴露整个组件对象来实现。button.vue <button @click="handleClick"><button>props:{ funcProps: {...原创 2018-07-23 09:51:20 · 4288 阅读 · 0 评论 -
map() (es6)
map() (es6)map()的实例是{key:value}结构,但不同于Object.Map 结构的实例有以下属性和操作方法。 (1)size 属性 (2)set(key, value) (3)get(key) (4)has(key) (5)delete(key) (6)clear()遍历方法 keys():返回键名的遍历器。 values():返回键值的遍历器。...原创 2018-07-11 11:45:23 · 899 阅读 · 0 评论 -
Set()方法es6
Set()方法 (es6)set方法没有重复元素 (===)// 去除数组的重复成员[...new Set(array)]// 例一const set = new Set([1, 2, 3, 4, 4]);[...set]// [1, 2, 3, 4]// 例二const items = new Set([1, 2, 3, 4, 5, 5, 5, 5])...原创 2018-07-11 11:37:49 · 1178 阅读 · 0 评论 -
数组方法汇总
数组方法汇总Array.length 返回或设置一个数组中的元素个数 设置 length 属性的值来截断任何数组Array.from() 语法 Array.from(arrayLike, mapFn, thisArg) arrayLike 想要转换成数组的伪数组对象或可迭代对象。 mapFn (可选参数) 如果指定了该参数,新数...原创 2018-07-11 10:51:06 · 128 阅读 · 0 评论 -
Object对象
Object对象方法汇总Object.assign(target, …sources) target:目标对象。 sources: 原对象 返回值为对象常用:复制对象var obj = { a: 1 };var copy = Object.assign({}, obj);console.log(copy); // { a: 1 }合并对象...原创 2018-07-11 09:44:36 · 137 阅读 · 0 评论 -
数组多重条件过滤的方法
数组多重条件过滤的方法let array = [{ date: '2016-05-02', name: 'Ethan', status: 'success', total: '81'},{ date: '2016-05-04', name: 'Lynn', status: 'fail', tag: '50'},{ date: '2016-05-01'...转载 2018-07-16 16:55:02 · 2421 阅读 · 0 评论 -
generator(生成器)
形式上,Generator 函数是一个普通函数,但是有两个特征。一是,function关键字与函数名之间有一个星号;二是,函数体内部使用yield语句,定义不同的内部状态function* helloWorldGenerator() { yield 'hello'; yield 'world'; return 'ending';}var hw = helloWorldGener...转载 2018-05-15 15:08:24 · 405 阅读 · 0 评论 -
map、reduce、filter、sort
let arr = [1, 3, 5, 7, 9];let a = arr.map((item,index) => { return item*index;});console.log(a)Array的reduce()把一个函数作用在这个Array的[x1, x2, x3…]上,这个函数必须接收两个参数,reduce()把结果继续和序列的下一个元素做累积计算var ar...转载 2018-05-15 14:02:33 · 133 阅读 · 0 评论 -
ES6 解构用法
var person = { name: '小明', age: 20, gender: 'male', passport: 'G-12345678', school: 'No.4 middle school'};var {name, age, passport} = person;console.log('name = ' + name + ', ag...转载 2018-05-15 10:20:23 · 247 阅读 · 0 评论 -
...rest传参
…rest可以灵活使用,取代argumentsfunction foo(a, b, ...rest) { console.log('a = ' + a); console.log('b = ' + b); console.log(rest);}转载 2018-05-15 09:54:20 · 1527 阅读 · 0 评论 -
es6中的Map和Set,for ... of
Map是一组键值对的结构,具有极快的查找速度。得到的是一个对象。var m = new Map([['Michael', 95], ['Bob', 75], ['Tracy', 85]]);var a = [['Michael', 95], ['Bob', 75], ['Tracy', 85]];console.log(m)console.log(a)// Map的增删改查va...转载 2018-05-15 09:48:49 · 406 阅读 · 0 评论 -
数组的交集和并集
let a = new Set([1, 2, 3]);let b = new Set([3, 5, 2]); // 并集let unionSet = new Set([...a, ...b]);//[1,2,3,5]// 交集let intersectionSet = new Set([...a].filter(x => b.has(x)));// [2,3]// ab...转载 2018-05-14 14:02:40 · 1100 阅读 · 0 评论 -
关于import ,export 命令
在CommonJS 中// CommonJS模块 let { stat, exists, readFile } = require('fs');// 等同于 let _fs = require('fs'); let stat = _fs.stat; let exists = _fs.exists; let readfile = _fs.readfile;而ES6 模块不是对象,...转载 2019-02-21 09:38:14 · 446 阅读 · 0 评论