how can be a collection of global and/or local varibles be obtained in javascript?
(like e.g. in Python by globals() or locals())
if there is no such functionality available in javascript, how do some javascript console interfaces obtain them, to be able to autocomplete?
You’re looking for the
for/inloop.To get all globals:
(This will only work correctly when run in global scope; you can wrap it in an anonymous function to ensure that. However, beware of
withblocks)To get all properties of a particular object:
However, there is no way to loop through all local variables.