随笔分类 - JavaScript
摘要:借助API compositionstart文本合成系统如 input method editor(即输入法编辑器)开始新的输入合成时会触发 compositionstart 事件。compositionend当文本段落的组成完成或取消时,compositionend 事件将被触发(具有特殊字符的触
阅读全文
摘要:const number= 电话号码 window.location.href='tel://'+number 接下来就会看到
阅读全文
摘要:function a(a, b) { this.aa = 1; console.log(this, a, b); } function b(a, b) { this.bb = 2; console.log(this, a, b); } function c(a, b) { this.cc = 2;
阅读全文
摘要:function *syncMethod() { yield 111; yield 222; yield 3333; return 4444; } let generator = syncMethod(); console.log(generator.next()); // {value: 1, d
阅读全文
摘要:base64编码/解码 var str = "RUNOOB"; var enc = window.btoa(str); //编码 var dec = window.atob(enc); //解码 var res = "编码字符串为: " + enc + "<br>" + "解码后字符串为: " +
阅读全文
摘要:'CSS' in window //返回结果是true或者false 来看下面案例 检查pepole对象上是否存在名为css键 let pepole={css:function(){console.log('this is css')}}; 'css' in pepole // true 检查pep
阅读全文
摘要:eval() 函数计算 JavaScript 字符串,并把它作为脚本代码来执行。 如果参数是一个表达式,eval() 函数将执行表达式。如果参数是Javascript语句,eval()将执行 Javascript 语句。 eval(string) eval("x=10;y=20;document.w
阅读全文
摘要:URL特殊符号转码 encodeURIComponent('/') '%2F' decodeURIComponent('%2F') '/'
阅读全文
摘要:forEach 、for of 1、数组的元素是基本数据类型:(X) [1] 2、数组的元素是引用数据类型:(直接修改引用,X) [{}] 3、数组的元素是引用数据类型:(修改引用对象内属性,√) [{a:1}]
阅读全文
摘要:字符转ASCII码:用str.charCodeAt(); ASCII码转字符:用String.fromCharCode(65);
阅读全文
摘要:<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title></title> <style typ
阅读全文
摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document<
阅读全文
摘要:var f = '99999999999'.replace(/\d{1,3}(?=(\d{3})+$)/g, '$&,') console.log(f)
阅读全文
摘要:console.time("timeTest"); 代码区域 coneole.timeEnd("timeTest");
阅读全文
摘要:什么是柯理化? 柯理化(Currying)是把接受多个参数的函数变换成接受一个单一参数(最初函数的第一个参数)的函数,并且返回接受余下的参数且返回结果的新函数的技术。 普通函数 //函数定义 function add(a,b){ return a + b } //函数调用 add(1, 2); 柯理
阅读全文
摘要:while遍历 可以使用 break, continue ,return 普通for循环 可以使用 break, continue,不能return forEach 遍历数组 可以抛出异常 throw new Error("这个是异常")不能 break,continue,return for...
阅读全文
摘要:__proto__是原型,原型链就是一直查找__proto__ ,直到返回值为null。 (new对象.__proto__.__proto__.__proto__) 返回值为null
阅读全文
摘要:clientX 以浏览器左上顶角为原点,定位 x 轴坐标clientY 以浏览器左上顶角为原点,定位y轴坐标offsetX 以当前事件的目标对象左上角为原点,定位x轴坐标offsetY 以当前事件的目标对象左上角为原点,定位y轴坐标pageX 以Document 对象(即文本窗口)左上角为原点,定位
阅读全文

浙公网安备 33010602011771号