JavaScript
KAHOZ
这个作者很懒,什么都没留下…
展开
-
ES6( let 与 const )
用var声明的变量会造成全局污染,于是,就产生了新的声明方式。 let 用 let 声明变量,要先声明后使用。 for(let i = 0; i < 10; i++) { console.log(i); //0-9 } console.log(i); //结果:undefined const const声明一个只读的常量。一旦声明,常量的值就不能改变。 const PI = 3.1415; PI=3; //报错:TypeError: Assignment to constant variable.原创 2021-03-27 16:41:34 · 57 阅读 · 0 评论 -
Promise 笔记
使用promise封装Ajax异步请求 function ajax(url){ return new Promise((resolve,reject)=>{ let xhr=new XMLHttpRequest() xhr.open('GET',url) xhr.send() xhr.onload=function(){ if(this.status===200){ reso原创 2021-03-31 12:53:48 · 69 阅读 · 0 评论