欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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 | white-space | Math.random() | Set object | Array.isArray() | Object.keys() |Array.from()

position: relative;

position | white-space | Math.random() | Set object | Array.isArray() | Object.keys() |Array.from()

position: absolute;

position | white-space | Math.random() | Set object | Array.isArray() | Object.keys() |Array.from()

二.white-space
【参考】https://developer.mozilla.org/zh-CN/docs/Web/CSS/white-space

position | white-space | Math.random() | Set object | Array.isArray() | Object.keys() |Array.from()

white-space: normal;

position | white-space | Math.random() | Set object | Array.isArray() | Object.keys() |Array.from()

white-space: nowrap;

position | white-space | Math.random() | Set object | Array.isArray() | Object.keys() |Array.from()

white-space: pre;

position | white-space | Math.random() | Set object | Array.isArray() | Object.keys() |Array.from()

white-space: pre-wrap;

position | white-space | Math.random() | Set object | Array.isArray() | Object.keys() |Array.from()

white-space: pre-line;

position | white-space | Math.random() | Set object | Array.isArray() | Object.keys() |Array.from()

三.随机排序数组中的数值—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);

不足:

position | white-space | Math.random() | Set object | Array.isArray() | Object.keys() |Array.from()

position | white-space | Math.random() | Set object | Array.isArray() | Object.keys() |Array.from()

position | white-space | Math.random() | Set object | Array.isArray() | Object.keys() |Array.from()

五.other points

Array.isArray(arr)

position | white-space | Math.random() | Set object | Array.isArray() | Object.keys() |Array.from()

Object.keys()

position | white-space | Math.random() | Set object | Array.isArray() | Object.keys() |Array.from()

Array.from()

Chrome[60.0.3112.101] :
position | white-space | Math.random() | Set object | Array.isArray() | Object.keys() |Array.from()

Opera[ 47.0.2631.55] :
position | white-space | Math.random() | Set object | Array.isArray() | Object.keys() |Array.from()

Firefox[55.0.2] :
position | white-space | Math.random() | Set object | Array.isArray() | Object.keys() |Array.from()

document.default.getComputedStyle()

position | white-space | Math.random() | Set object | Array.isArray() | Object.keys() |Array.from()