11 2019 档案
摘要:// ① 当函数中没有this时,call()、apply()和直接执行没有区别 function fn(){ console.log("aaa") } fn() // aaa fn.call() // aaa fn是函数,函数也是对象,对象调用call()方法 fn.apply() // aaa
阅读全文
摘要:什么是继承? A对象通过继承B对象,就可以拥有B对象的所有属性和方法。 原型链继承: 子类的原型是父类的实例,子类继承父类的所有私有属性、私有方法和其原型上的属性和方法。 // 定义父类Person function Person(name,age){ this.name=name; this.ag
阅读全文
摘要:网页禁止复制并且右键失效: 第一种方法: <script> document.oncontextmenu=new Function("event.returnValue=false"); document.onselectstart=new Function("event.returnValue=f
阅读全文
摘要:概念理解: 数组的解构赋值 对象的解构赋值 字符串的解构赋值 数值和布尔值的解构赋值 函数参数的解构赋值 数组的解构赋值: 一般的: const arr=[1,2,3,4]; let [a,b,c,d]=arr; console.log(a,b,c,d) // 1 2 3 4 复杂点的: const
阅读全文
摘要://通过id名称获取元素对象 function getid(idName){ return document.getElementById(idName); } //随机获取min-max的随机整数 function getRand(min,max){ return parseInt(Math.ra
阅读全文
摘要:需求:在1秒内,由一个颜色变到另一个颜色,不是1秒后再变色。 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initi
阅读全文
摘要:<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>DIV+CSS+JS实现色彩渐变字体</title> <style type="tex
阅读全文
摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0,
阅读全文
摘要:什么是generator函数: 在js中,一个函数一旦执行,就会运行到最后或者遇到return时结束,运行期间不会有其它代码能打断它,也不能从外部再传入值到函数体内。 generator函数的出现就可以打断一个函数的完整运行,语法和传统函数完全不同。 generator是ES6提供的一种异步变成解决
阅读全文
摘要:递归求斐波那契数列: //1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368........ function getFib(n){ if(n==
阅读全文
摘要:日期转换成时间戳: 安卓下可以使用 Date.parse(new Date('2019-11-18 12:00:00')) 直接转换,结果为 1574049600000 ios下 Date.parse(new Date('2019-11-18 12:00:00')) 无法转换,需要写成Date.pa
阅读全文
摘要:先来一段基本布局 <!doctype html> <html> <head> <meta charset="utf-8"> <title>无标题文档</title> <style> .container { display: grid; grid-template-columns: 100px 10
阅读全文
摘要:什么是终端:操作系统分为两个部分,一部分为内核,一部分为用户交互界面。终端是连接内核和交互界面的桥梁。 echo "上善若水,厚德载物":将所说的话打印出来 ls:查看当前文件夹列表 ls -a:查看当前文件夹下的所有文件,包括隐藏文件 ls -R:查看当前文件夹列表及其所有子文件(一般用ls -a
阅读全文
摘要:function fn(){ return "aa"; } console.log(fn())// 如果直接写个函数return一个值,那么打印的肯定就是aa async function fn(){ return "aa"; } console.log(fn())// 使用async就是在函数前面
阅读全文
摘要:<!doctype html> <html> <head> <meta charset="utf-8"> <title>无标题文档</title> <style type="text/css"> div{ width:100px; height:100px; background-color:#CC
阅读全文
摘要:安装: npm i image-conversion --save引入: <script src="https://cdn.jsdelivr.net/gh/WangYuLue/image-conversion/build/conversion.js"></script> or const image
阅读全文
摘要:encodeURI(): 对整个URL进行编码,对应的解码方式:decodeURI() encodeURIComponent() : 对查询字符串进行编码,对应的解码方式:decodeURIComponent() 注意:不要使用escape()和unescape()方法。
阅读全文
摘要:// 判断input框(除了类名为min1和max7)是否为空 function isEmpty(){ var flag=true; $("input[type='text']").not(".min1").not(".max7").each(function(i,item){ if(item.va
阅读全文
摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> table { border-collapse: collapse; } td { border: 1px soli
阅读全文
摘要:setChecked(); function setChecked(){ var length=$("input[type=checkbox]").length; for(let i=0;i<length+1;i++){ var check=$(".check"+i); check.click(fu
阅读全文
摘要:<body> <input type="text" placeholder="只能输入数字"> <script src="https://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script> <script> $("input").on("inpu
阅读全文