[removed] enumerate global vars

前端 未结 3 899
南旧
南旧 2021-01-27 05:52
a = 123; // becomes global var

var b = 234; // local var

function f() {} // local func

g = function() {} // got a global func

now how to print

3条回答
  •  有刺的猬
    2021-01-27 06:41

    How about:

    var globals = window || global;
    for (var key in globals){
      console.log(window[key]);
    }
    

提交回复
热议问题