首页
AI Coding
NEW
沸点
课程
直播
活动
AI刷题
APP
插件
搜索历史
清空
创作者中心
写文章
发沸点
写笔记
写代码
草稿箱
创作灵感
查看更多
会员
登录
注册
es6
你眼中的光
创建于2024-02-26
订阅专栏
es6方法
暂无订阅
共44篇文章
创建于2024-02-26
订阅专栏
默认顺序
默认顺序
最早发布
最新发布
暴露模块
``` 分别暴露 m1.js export let shool='尚硅谷'; export function teach(){ console.log("我们试试看"); } html 统一暴露 m2
class类的get和set
``` class phone{ get price(){ console.log('价格属性被读取'); return '价格'; } set price(){ console.log('价格属性被
class子类方法重写
在子类中使用与父类同名的方法,重写方法,重写后,只能调取子类的重写方法,无法调取改写的父类方法 class smartphone extends phone
class类继承
``` class phone{ constructor(brand,price){ this.brand=brand; this.price=price; } call(){ console.log
ES5构造函数继承
``` function Phone(brand,price){ this.brand=brand; this.price=price; } phone.prototype.call=fucntion
class静态成员
函数对象与实例对象不相通。 函数的原型对象prototype与实例对象相通。 函数的对象的方法和属性是静态成员,归属于函数
class
class 引入类概念,作为对象的模板,通过class,定义类。 function phone(brand,price){ this.brand=brand; this.price=price; }
map
类似于对象,键值对的集合。可以使用扩展运算符和for...of,具有iterator接口。 let m=new map();
set 集合
类似于数组,可以使用扩展运算和 for...of,具有iterator接口 set实践 let result=[...new set(arr)];
then方法返回值
返回值是promise对象,对象状态由回调函数的执行结果决定 返回类型 1.非promise 成功的返回状态,返回值由return决定,没有return,返回值为undefined 2.promise
封装ajax
1.创建对象 const xhr=new XMLHttpRequest(); 2.初始化 xhr.open("GET","https://api.apiopen.top/get"); 3.发送 xhr
封装读取文件
``` const fs=require('fs'); fs.readFile('./resources/为学.md',(err,data)=>{ if(err) throw err; console
promise
``` const p=new promise(function(resolve,reject){ setTimeout(function(){ let data='数据库中的用户数据'; resol
生成器解决异步操作
``` function one(){ setTimeout({ console.log(111); iterator.next(); },1000) } function two(){ setTim
生成器
yield 代码分隔符,将代码分块执行 参数传递 let interator=gen('aaa'); 或 interator.next('aaa') 返回上一个执行next的实参
迭代器
任何数据结构只要部署Iterator接口,就可以完成遍历操作,ES6提供for...of循环 for...in 循环索引 for...of 循环键值 工作原理 创建一个指针对象,指向数据结构的起始位置
symbol
类似于字符串的数据类型 用于解决命名冲突问题 不能与其他数据进行运算 不能使用for...in循环遍历,使用reflect.ownkeys获取对象的所有键名 创建symbol symbol创建对象 向
扩展运算符
好比 rest 参数的逆运算,将一个数组转为用逗号分隔的参数序列。 对象的扩展运算符用于取出参数对象的所有可遍历属性,拷贝到当前对象之中。 拷贝对象属性到当前对象 由于数组是特殊的对象,所以对象的扩展
rest参数
ES6引用rest参数,获取函数实参,形参的接收值为数组 rest参数要放到形参最后面 实参除了第一个参数赋值给a,后面的实参会通过rest参数数组形式接收,用于参数不确定的场景或累加处理的场景
函数参数的默认值
函数形参可以赋默认值,具有默认值的形参放到形参的后面 函数形参使用解构赋值 function connect({host='112',username,password,port})
下一页