自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(8)
  • 收藏
  • 关注

原创 多种数组去重方法

let arr = [4, 1, 2, 2, 3, 2, 1, 4, 4]; // 方法一 Es6 set方法 function unique1(arr) { return Array.from(new Set(arr)) } console.log('Es6 set方法---', unique1(arr))//[4, 1, 2, 3] // 方法二 indexof function unique2(arr){ let result = [] for(let i = 0,len=

2021-11-30 15:33:14 164

原创 手写深拷贝

<script type="text/javascript"> // 判断数组或对象类型 function cloneType(target) { return Object.prototype.toString.call(target).slice(8, -1) } // 手写一个深拷贝 function deepCopy(target) { let result; if (cloneType(target) === 'Object') { result = {}

2021-11-30 15:31:00 261

原创 数组扁平化

手写数组扁平化 什么是数组扁平化? 数组扁平化是指将一个多维数组变为一维数组

2021-11-30 15:28:16 209

原创 手写防抖节流

<!DOCTYPE html><html> <head> <meta charset="utf-8"> <title>手写防抖节流</title> </head> <body> <div> <ul> <li> <h3>防抖概念:</h3> <p>在短时间内多次触发同一个函数,如果n秒内高频

2021-11-30 15:19:46 103

原创 手写一个instanceOf

<script type="text/javascript"> // instanceof 运算符用于测试构造函数的 prototype 属性是否出现在对象原型链中的任何位置。 // 首先 instanceof 左侧必须是对象, 才能找到它的原型链 // instanceof 右侧必须是函数, 函数才会prototype属性 //迭代 , 左侧对象的原型不等于右侧的 prototype时, 沿着原型链重新赋值左侧 function instanceOf(left, right) {

2021-11-30 15:12:03 195

原创 手写new

//new的实现过程(实际上就是调用这个构造函数,同时将构造函数的prototype上的属性方法挂上去)//新建一个对象//对象继承构造函数的原型链//将构造函数的this指向这个对象//根据构造函数的返回值的返回结构function _new(fn) {//定义一个空对象let obj = {};//将传入的构造函数的prototype属性方法复制到obj里面obj = Object.create(fn.prototype)console.log(‘obj====’,obj)// 获

2021-11-30 15:04:53 58

转载 监测数组变化,并返回数组长度

const ArrayProto = []// console.log(‘Array.prototype===’,Array.prototype)Object.getOwnPropertyNames(Array.prototype).forEach(method => {//console.log(‘method====’,method)数组自带的一些属性 方法 例如:length,push,pop,concat等if (typeof Array.prototype[method] === “

2021-11-30 15:03:43 401

原创 手写promise

在这里插入代码片 详解手写promise Promise 基本特征 promise:有三个状态:pending,fulfilled,rejected executor接受两个参数分别是resolve和reject,Promise构造函数执行时会立即调用executor函数 当调用resolve(成功),状态:pengding=>fulfilled。当调用reject(失败),状态:pending=>rejected

2021-11-30 14:51:11 300

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除