![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
js
Joe爷
这个作者很懒,什么都没留下…
展开
-
js异步随记
/*回调函数获取异步方法里的数据*/function getData(callback) { setTimeout(function () { var name = "李四"; callback(name); },1000)}//外部获取异步方法里面的数据getData(function (data) { console.log(...原创 2019-08-23 17:00:10 · 70 阅读 · 0 评论 -
await async随记
//1、普通方法function getData() { return 'hello'}console.log(getData())/** 2、async 是让方法变成异步** */async function getData() { return 'hello'}console.log(getData());var p = getData();p.t...原创 2019-08-24 10:11:50 · 95 阅读 · 0 评论 -
es5中的类和静态方法
//es5中的类和静态方法function Person(name,age) { this.name = name; this.age = age; this.run = function () { console.log(`${this.name}——${this.age}`); }}//原型链上面的属性和方法可以被多个实例共享Pers...原创 2019-08-26 17:34:43 · 862 阅读 · 0 评论 -
es5原型链继承和对象冒充继承
/*es5原型链继承和对象冒充继承 对象冒充继承:没法继承原型链上面的属性和方法 原型链继承:可以继承构造函数里面以及原型链上面的属性和方法,实例化子类的时候没法给父类传参* */function Person(name,age) { this.name = name; this.age = age; this.run = function () { ...原创 2019-08-27 09:56:37 · 189 阅读 · 0 评论 -
Es6中的类、静态方法、继承.js
//定义类class Person{ constructor(name,age){ this.name = name; /*类的构造函数,实例化的时候执行,new的时候执行*/ this.age = age; } getName(){ console.log(this.name); } setName(...原创 2019-08-27 11:39:55 · 254 阅读 · 0 评论 -
es6单例(作用:只连接一次数据库)
class Dd{ static getInstance(){ if (!Dd.instance){ Dd.instance = new Dd(); } return Dd.instance; } constructor(){ /*实例化的时候就会执行*/ this....原创 2019-08-27 12:00:43 · 356 阅读 · 0 评论