<script> //演示bind函数的使用 function count(a, b) { return a + b + this.c; } let num = { c: 20 }; let numCount = count.bind(num, 10, 30)
<script> //先演示apply函数使用 function add(a, b) { return a + b + this.c; } let obj = { c: 520 } // add.apply(obj,[10,20]);
<script> //先演示如何使用call函数 //call函数会自动调用 function Father() { console.log(this.name); } let son = { name: '海绵宝宝' } Father.call
Date.parse()//Date.parse()方法接收一个表示日期的字符串参数,尝试将这个字符串转换为表示该日期的毫秒数//如果接收的参数并不表示日期,则该方法返回NaNlet someDate = Date.parse();console.log(someDate);// NaNlet someDate2 = Date.parse('2021-08-24 00:00:00');consol
String<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=
encodeURIComponent(编码)let encodeBase = encodeURIComponent();decodeURIComponent(解码)let decodeBase = decodeURIComponent();
<script> //个人感觉是两边都调用了Number console.log(true == 1); // 1==1 ---- true console.log(true == '1'); // 1==1 ----true console.log(1 == '2'); // 1==2 ---- false co
Math对象属性<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="widt
JavaScript垃圾回收
Copyright © 2005-2024 51CTO.COM 版权所有 京ICP证060544号