尧图网站设计 尧图网站设计YAOTU DESIGN
ARTICLE DETAIL

资讯详情

深耕网站设计与一线实操的经验洞察。

笔试题常见js操作

笔试题常见js操作 js代码封装// 获取扩展名 let filename = 'js.html'; let index = filename.lastIndexOf('.'); let suffix = filename.substring(index + 1); //从.加一 到最后 // let suffix = filename.substr(index+1); let spl = filename.split('.'); console.log(suffix, spl[spl.length - 1]); // 数组随机排序1 let arrpx = [1, 2, 3, 4, 6, 5, 7, 9, 8]; function randpx(arr) { for (let i = 0; i arr.length; i++) { let rand = parseInt(Math.random() * arr.length); let temp = arr[rand]; arr[rand] = arr[i]; arr[i] = temp; } return arr; } console.log(randpx(arrpx)); // sort排序2 let arrpx2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; arrpx2.sort(function() { return Math.random() - 0.5; }) console.log(arrpx2); let div = document.getElementById('box'); console.log(div.style['color']) var get
返回列表