# big-frontEnd **Repository Path**: itwangyang_coder/big-front-end ## Basic Information - **Project Name**: big-frontEnd - **Description**: 大前端 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2021-10-14 - **Last Updated**: 2021-10-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 大前端 ## 01.Promise ### 1.1、小试牛刀 ```javascript const promise = new Promise((resolve, reject) => { setTimeout(()=>{ console.log('promise resolve'); resolve() },1000) }) promise.then(()=>{ console.log("promise resolve callback"); }) ``` * 总结: ```text promise 有三种状态: pending,resolve,reject,进行中状态是可以修改的,其余的都是无法修改的 then可以执行完成后的回调函数 已拒绝的,可以catch进行捕获 ``` ### 01.2、学以致用 ```javascript function ajaxAsync(methods="GET",url){ return new Promise((resolve, reject) => { let xml = new XMLHttpRequest(); xml.open(methods,url); xml.onreadystatechange = function (){ if (this.readyState !== 4){ return; } if (this.status === 200){ resolve(this.response) }else { reject(new Error(this.statusText)) } }; xml.send(); }) } ajaxAsync('GET','./ajax.json').then(res=>{ console.log('成功',JSON.parse(res).data) }).catch(err=>{ console.log('失败', err); }) ``` - json数据 ```json { "data": { "name": "wangyang", "age": 18 } } ``` ## 02. amd、cmd、common、ES6模块化 - 这个以后补充 ## 03. 闭包,作用域,原型链,this ![img.png](makedownImg/img.png) ## 04. 构造函数、面向对象 ### 4.1. 构造函数 ```javascript // 构造函数 function Person(name,age){ this.name = name; this.age = age; this.sayHi = function (){ console.log(`hello; my name is ${this.name},now ${this.age}`) } } const p1 = new Person('wang',14); const p2 = new Person('yang',18); console.log(p1 === p2) // 缺点: 每次都是要开辟一个内存空间 ``` ## 05. react