Javascript equivalent of Python's locals()?

后端 未结 6 1565
离开以前
离开以前 2020-11-29 11:54

In Python one can get a dictionary of all local and global variables in the current scope with the built-in functions locals() and globals(). Is t

6条回答
  •  無奈伤痛
    2020-11-29 12:25

    • locals() - No.

    • globals() - Yes.

    window is a reference to the global scope, like globals() in python.

    globals()["foo"]
    

    is the same as:

    window["foo"]
    

提交回复
热议问题