2024年07月30日 //定义打印前事件 var beforePrint = function() { console.log("beforePrint"); }; //定义打印后事件 var afterPrint = function() { console.log("afterPrint"); } //监听window状态 if (window.matchMedia) { var mediaQueryList

2024年07月30日 var text = '你是我的家,我是你的他,今年十一去见他,一起去看他'; //把所有“他”替换成“它” var result = text.replace(/\他/g,'它'); Ps:\为转义字符 g表示全局 console.log(result) //结果输出

2024年07月30日 基础数据 let eduLevelArray = [ { id: "1", name: "张三", edu: "小学" },{ id: "2", name: "李四", edu: "初中" },{ id: "1", name: "张三", edu: "高中" },{ id: "2", name: "李四", edu: "大学" },{ id: "3", n

2024年07月30日 //判断是否在app中打开 if (navigator.userAgent.indexOf("Html5Plus") < 0) { //在浏览器打开 console.log('我来自非app') } else { //在app打开 console.log('我来自app') }

2024年07月29日 function base64Encode (str) { return btoa(encodeURIComponent(str)); } function base64Decode (str) { return decodeURIComponent(atob(str)); } var b = base64Encode('web建站入门教程'); var a = base64Decode(b); console.log('b

2024年07月29日 方法一、数组字符串化 let arr = [[222, 333, 444], [55, 66, 77], {a: 1} ] arr += ''; arr = arr.split(','); console.log(arr); // ["222", "333", "444", "55", "66", "77", &

2024年07月29日 //方法一接口 function configUrlCodeWebApi(callback){ var webData = {} if (callback) { callback(webData) } }) 方法二接口 configUrlCodeWebApi(function(apiData){ executionInterfaceApi(apiData) })

2024年07月29日 1、ES6判断数组是否存在重复元素 let arr = [1, 2, 3, 4, 5, 2, 3]; if ((new Set(arr)).size != arr.length) { console.log('数组有重复值') } 2、获取数组重复的元素 repeat(arr) { var tmp = []; if (Array.isArray(arr)) { arr .concat() .sort

2024年07月29日 function twoTimeInterval(startTime, endTime) { // 开始时间 let d1 = startTime.replace(/\-/g, "/"); let date1 = new Date(d1); // 结束时间 let d2 = endTime.replace(/\-/g, "/"); let date2 = new Date(d2);

2024年07月29日 1、参数介绍 var msg = new SpeechSynthesisUtterance(); msg.rate = 4 播放语速 msg.pitch = 10 音调高低 msg.text = "播放文本" msg.volume = 0.5 播放音量 window.speechSynthesis.speak(msg); 2、调用方法 //播放 window.speechSynthesis.speak(); //暂停 w

2024年07月29日 var arr=[{name:122,age:12},{name:1122,age:122}] var arr2 = [] //方法1: for(var i=0; i<arr.length; i++){ arr2.push({ [`name` + (i + 1)]:arr[i].name, [`age` + (i + 1)]:arr[i].age }) } //方法2: var arr=[{name:122,age:12}

2024年07月29日 //把多维数组children降维到平级 1、数据 let data = [{ hosp:'北京一院', type:'门诊', children:[ {name1:1, num1:11}, {name2:22,num2:23}, {name3:32,num3:33}, {name4:42,num4:43} ] },{ hosp:'上海协和医院', type:'住院

2024年07月29日 最终格式: var logs = [{ examNos:["200904760062"], id: "809bd3003dba", },{ examNos:["200904760062","200904760060"], id: "809bd3003dba1111", },{ examNos:["200904760062"

2024年07月29日 var items = [ {name:'小白',age:'23'}, {name:'小白2',age:'23'}, {name:'小白3',age:'23'}, {name:'小白4',age:'23'}, {name:'小白5',age:'23'}, {name:'小白6'

2024年07月29日 let data = [{name:'张三',age:23,sex:'男'},{name:'李四',age:23,edu:'本科'}] for(let i=0; i<data.length; i++){ console.log('输出结果', data[i].hasOwnProperty('edu')) } //输出结果 false //输出结果 t

最新内容