ghost2113

Results 8 comments of ghost2113

``` Object.prototype.MyIndexOf = function(str, from=0){ let data = this; let isArray = Array.isArray(data); let isString = Object.prototype.toString.call(data) == '[object String]'; if (!isArray && !isString) throw new SyntaxError(); let len =...

``` // output '1~3,5,7~9,11~12' var str = '1,2,3,5,7,8,9,11,12'; function simplifyStr(str) { var arr = str.split(',').map(item => parseInt(item)); let result = arr.map((current, index) => { var next = arr[index + 1]...

> ``` > let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] > function sort(arr) { > let pre = [] > while...

> Object.values(map) 将对象转为数组 > 学习了 Object.values()只是获取对象可枚举属性的value值,返回一个数组

typeof name == 'undefined'首先会在IIFE作用域寻找变量**name**,未寻找到,会通过作用域链向上级作用域继续寻找,通过IIFE调用位置知道上级作用域为window

` function getRandomArrayfromBigArray(newLength, sourceLength) { var sourceArr = Array.from({length: sourceLength}, (item, i) => i); var newArr = []; var temp; var randomIndex; for(var i = 0; i

// 只适用于多行文本一定会溢出的情况 @mixin multiLineEllipsis($lineHeight: 1.2em, $lineCount: 1, $bgColor: white){ overflow: hidden; position: relative; line-height: $lineHeight; max-height: $lineHeight * $lineCount; text-align: justify; margin-right: -1em; padding-right: 1em; &:before { content: '...'; position:...