Global、UUID

166 阅读1分钟

1.当一个函数在没有明确(通过成为某个对象的方法,或者通过 call()/apply())指定 this 值的情况下执行时,this 值等于Global 对象。因此,调用一个简单返回 this 的函数是在任何执行上下文中获取 Global 对象的通用方式。

let global = function() {
   return this
}();

2.生成UUID

window.crypto.randomUUID()