摘要: 函数闭包:内部函数可以访问定义他们外部函数的参数和变量。作用域链的向上查找,把外围的作用域中的变量值存储在内存中而不是在函数调用完毕后销毁,设计私有的方法和变量,避免全局变量的污染。闭包简单来说就是一个函数访问了它的外部变量。 1 var quo = function(status){ 2 retu 阅读全文
posted @ 2021-11-22 11:26 wechary 阅读(134) 评论(0) 推荐(0)
摘要: typeof typeof运算符返回一个用来表示表达式的数据类型的字符串。 返回值为6个字符串,分别为string、Boolean、number、function、object、undefined。 let a = [1,2,3], b = 1, c = 'test', d = function() 阅读全文
posted @ 2021-07-20 14:22 wechary 阅读(747) 评论(0) 推荐(0)
摘要: 1、判断变量数据类型 function getValuetType(value) { return Object.prototype.toString.call(value) } 2、数组去重 function unique1(arr) { return [...new Set(arr)] } fu 阅读全文
posted @ 2021-07-20 14:03 wechary 阅读(41) 评论(0) 推荐(0)