![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
手写篇
手写篇
一只金牛座的崽
这个作者很懒,什么都没留下…
展开
-
实现rem基本功能
rem 基本设置 // 提前执行,初始化 resize 事件不会执行 setRem() // 原始配置 function setRem () { let doc = document.documentElement let width = doc.getBoundingClientRect().width //除以3.75 在375的分辨率时html的font-size是100px, //方便计算(淘宝是这么计算的) let rem = width / 3.75 doc.style.原创 2021-07-26 11:35:56 · 103 阅读 · 0 评论 -
递归实现深拷贝
文章目录一、递归实现深拷贝 一、递归实现深拷贝 function copyData(obj) { if (!obj|| typeof obj !== 'object') { return false } let newObj = obj instanceof Array?[]:{} // 用for in 循环对象 但他会枚举到原型的属性 for (let key in obj) { // hasOwnProperty过滤掉原型上的属性 if (obj.hasOwnProperty原创 2021-11-08 18:57:22 · 135 阅读 · 0 评论 -
常见排序算法
文章目录一、冒泡排序二、快速排序三、选择排序四、插入排序 一、冒泡排序 function sort(array) { var temp for(let i=0;i<array.length-1;i++){ for(let j=0;j<array.length-1-i;j++) { if (array[j]>array[j+1]) { temp = array[j] array[j] = array[j+1] array[j+1] = temp原创 2021-10-11 14:10:37 · 37 阅读 · 0 评论 -
手写AJAX
文章目录一、AJAX 一、AJAX var request = new XMLHttpRequest() request.onreadystatechange = function () { if (this.readyState===4&&this.status === 200) { console.log('log',request.responseText); } } request.open('GET', 'http://xxxx/mock/164/xxx/dangdan原创 2021-10-11 14:10:25 · 95 阅读 · 0 评论 -
判断数据类型,手写instanceof
文章目录一、typeof二、instanceof一、判断数组类型三、手写实现instanceof 一、typeof console.log('typeof', typeof 123, typeof '123', typeof true, typeof {}, typeof null, typeof undefined ); //typeof number string boolean object object undefined null类型是object 二、instanceof i原创 2021-10-15 15:42:54 · 113 阅读 · 0 评论