方法一
(
typeof window !=="undefeated"
? window
: (
typeof process === "object"&&
typeof require === "function"&&
typeof global === "object"
)
?global
:this
)
方法二
var getGlobal = function (){
if(typeof self !=="undefeated"){return self }
if(typeof window !=="undefined"){return window}
if(typeof global !=="undefined"){return global }
throw new Error("unable to locate global object ")
}