a = 123; // becomes global var
var b = 234; // local var
function f() {} // local func
g = function() {} // got a global func
a
and (および現在g
までの他のすべてのグローバル変数) を出力する方法ですが、現時点ではb
and (およびその他のローカル変数) は出力しません。f
console.log(this)// is not working.
編集:「window」変数を使用する提案はブラウザでのみ機能しますが、埋め込まれた Javascript または Node.js には「window」変数がありません。