摘要: JavaScript 算法和数据结构 1.分割数组 function chunkArrayInGroups(arr, size) { let [start, end, result] = [null, null, []]; for (let i = 0; i < Math.ceil(arr.leng 阅读全文
posted @ 2021-08-04 15:29 想赚点零花钱 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 百度查了很多实现计时器的方法,这种方式实现计时器是比较稳定的好的方式。 原作者博客地址:https://blog.csdn.net/qq_40146789/article/details/109357665?utm_medium=distribute.pc_relevant.none-task-bl 阅读全文
posted @ 2021-07-20 09:27 想赚点零花钱 阅读(396) 评论(0) 推荐(0) 编辑
摘要: 1.forEach arr.forEach(function(value, index, array) { //参数一是:数组元素 //参数二是:数组元素的索引 //参数三是:当前的数组 }) //相当于数组遍历的 for循环 没有返回值 2.filter过滤数组 var arr = [12, 66 阅读全文
posted @ 2021-06-07 11:41 想赚点零花钱 阅读(86) 评论(0) 推荐(0) 编辑
摘要: 一.介绍call() - call()可以调用函数- call()可以修改this的指向,使用call()的时候 参数一是修改后的this指向,参数2,参数3..使用逗号隔开连接。 1.1 子构造函数继承父构造函数中的属性 1. 先定义一个父构造函数2. 再定义一个子构造函数3. 子构造函数继承父构 阅读全文
posted @ 2021-06-07 11:31 想赚点零花钱 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 一.构造函数原型prototype 构造函数原型prototype的出现是:节省内存空间 为了使构造函数的对象使用同一个方法,把那些不变的方法,直接定义在 prototype 对象上,这样所有对象的实例就可以共享这些方法。 function Star(uname, age) { this.uname 阅读全文
posted @ 2021-06-07 11:20 想赚点零花钱 阅读(81) 评论(0) 推荐(0) 编辑
摘要: <script> // 1.立即执行函数: 不需要调用,立马能够自己执行的函数 function fn() { console.log(1); } fn(); // 2. 写法 也可以传递参数进来 // 1.(function() {})() 或者 2. (function(){}()); (fun 阅读全文
posted @ 2021-05-23 10:52 想赚点零花钱 阅读(35) 评论(0) 推荐(0) 编辑
摘要: 举例: console.log(1); document.onclick = function() { console.log('click'); } setTimeout(function() { console.log(3) }, 3000) console.log(2); //结果:1,2,3 阅读全文
posted @ 2021-05-22 22:32 想赚点零花钱 阅读(42) 评论(0) 推荐(0) 编辑
摘要: this的指向在函数定义的时候是确定不了的,只有函数执行的时候才能确定this到底指向谁,一般情况下this的最终指向的是那个调用它的对象。 我们了解一下几个this指向: 全局作用域或者普通函数中this指向全局对象window(注意定时器里面的this指向window) 方法调用中谁调用this 阅读全文
posted @ 2021-05-22 22:28 想赚点零花钱 阅读(43) 评论(0) 推荐(0) 编辑
摘要: <div id="app"> <!--v-if: 当条件为false时, 包含v-if指令的元素, 根本就不会存在dom中--> <h2 v-if="isShow" id="aaa">{{message}}</h2> <!--v-show: 当条件为false时, v-show只是给我们的元素添加一 阅读全文
posted @ 2021-05-22 22:20 想赚点零花钱 阅读(50) 评论(0) 推荐(0) 编辑
摘要: 一.什么时候会用到: 二.和methods的区别: 举例: <div id="app"> <!--1.直接拼接: 语法过于繁琐--> <h2>{{firstName}} {{lastName}}</h2> <!--2.通过定义methods--> <!--<h2>{{getFullName()}}< 阅读全文
posted @ 2021-05-22 22:13 想赚点零花钱 阅读(50) 评论(0) 推荐(0) 编辑