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

来源:互联网 发布:索尼电视推荐 知乎 编辑:程序博客网 时间:2024/06/05 12:01

一. 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()

这里写图片描述

原创粉丝点击