随笔分类 -  JavaScript

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