VUE源码阅读收获js知识

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/crazyshoushou/article/details/83107061

1.是不是对象

Object.prototype.toString.call(obj) === '[object Object]'

2.是不是无穷的

isFinite(val)

3.删除数组元素

function remove (arr, item) {

    if (arr.length) {

        var index = arr.indexOf(item);

        if (index > -1) {

        return arr.splice(index, 1)

        }

    }

}

4.replace高级应用及占位符_

str.replace(/-(\w)/g, function (_, c) { return c ? c.toUpperCase() : ''; })

str.replace(hyphenateRE, '-$1').toLowerCase(

// 1.$i (i:1-99) : 表示从左到右正则子表达式所匹配的文本。 // 2.$&:表示与正则表达式匹配的全文本。 // 3.$`(`:切换技能键):表示匹配字符串的左边文本。 // 4.$'(‘:单引号):表示匹配字符串的右边文本。

// 5.$$:表示$转移。

5.// Firefox has a "watch" function on Object.prototype...

6.void 0 得到纯正的undefined

7常见的 macro task 有 setTimeout、MessageChannel、postMessage、setImmediate。而常见的 micro task 有 MutationObsever 和 Promise.then。

猜你喜欢

转载自blog.csdn.net/crazyshoushou/article/details/83107061