javascript
chenhqcc
这个作者很懒,什么都没留下…
展开
-
bind polyfill
bind usefunc.bind(thisArg[, arg1[, arg2[, …]]])thisArg改变目标函数this指向的值,若为基本类型将转化为基本类型对应的包装对象// bind使用function func(...arg){ console.log(this) console.log(arg)}let newFunc = func.bind([1,2...原创 2018-11-06 10:06:24 · 416 阅读 · 0 评论 -
es5class
基本类function Person(){ // 属性 this.name = 'zhangsan' this.age = 20 // 实例方法 this.run = () => { console.log( this.name + '在运动' ) }}let p = new Person()console.log(p...原创 2018-11-06 10:07:09 · 388 阅读 · 0 评论 -
ajax封装
function ajax(method, url, data, success){ /*1.创建一个ajax对象 ie6以下new ActiveXObject('Microsoft.XMLHTTP')*/ var xhr; if( window.XMLHttpRequest ){ xhr = new XMLHttpReque...原创 2018-11-06 10:14:26 · 108 阅读 · 0 评论 -
函数防抖debounce/函数节流throttle
函数防抖debounce函数节流throttle函数防抖:将几次操作合并为一此操作进行。原理是维护一个计时器,规定在delay时间后触发函数,但是在delay时间内再次触发的话,就会取消之前的计时器而重新设置。这样一来,只有最后一次操作能被触发函数节流:使得一定时间内只触发一次函数。原理是通过判断是否到达一定时间来触发函数var timeout = nullfunction deboun...原创 2018-11-06 16:55:26 · 414 阅读 · 0 评论 -
promise介绍
promise使用new Promise返回的对象称之为Promise对象三种状态: pending 正在进行 fulfilled 已完成 rejected 已失败1. new Promise 接收一个函数 executor2. 函数 executor 接收两个参数,resolve,reject 调用resolve的时候,把promise对象转成成功状态...原创 2018-11-09 15:28:40 · 251 阅读 · 0 评论 -
promise polyfill
promise polyfillv1.0 CustomePromise构造器定义,状态从pending变为fulfilled/rejected,并且不可逆;(function(){ // 定义三种状态 const status = { pending: 0, /*进行时*/ fulfilled: 1, /*成功*/ rejecte...原创 2018-11-09 15:33:57 · 1839 阅读 · 0 评论