position | white-space | Math.random() | Set object | Array.isArray() | Object.keys() |Array.from()
程序员文章站
2022-07-08 17:02:16
...
一. CSS 定位体系概述
【参考】http://www.w3help.org/zh-cn/kb/009/
①
position: static;
②
position: relative;
③
position: absolute;
二.white-space
【参考】https://developer.mozilla.org/zh-CN/docs/Web/CSS/white-space
①
white-space: normal;
②
white-space: nowrap;
③
white-space: pre;
④
white-space: pre-wrap;
⑤
white-space: pre-line;
三.随机排序数组中的数值—Again
var arr = [1,2,3,4,5,6];
function randomNum(arr){
var currentIndex = arr.length,
randomIndex,temp;
while(currentIndex !== 0){
randomIndex = Math.floor(Math.random()*currentIndex);
currentIndex--;
temp = arr[currentIndex];
arr[currentIndex] = arr[randomIndex];
arr[randomIndex] = temp;
}
return arr;
}
randomNum(arr);
四.数组去重
①
function unique(arr){
var temp = [];
for(var i = 0;i < arr.length;i++){
if(temp.indexOf(arr[i]) == -1){
temp.push(arr[i]);
}
}
return temp;
}
var arr = [1,2,3,2,3,1,4];
unique(arr);
不足:
②
五.other points
①
Array.isArray(arr)
②
Object.keys()
③
Array.from()
Chrome[60.0.3112.101] :
Opera[ 47.0.2631.55] :
Firefox[55.0.2] :
④
document.default.getComputedStyle()