Is there a way to get a javascript
reference to an object that was output to the chrome console?
For example, say I had the following javascript:
top.it = {hi:'there'};
console.log(top.it);
This would output to the chrome console as
Object {hi: "there"}
I do this alot, and sometimes would like to get a reference to the object in the console, to run methods on it, and things like that.
Is there a way to get a reference to objects that have been output using console.log
?
I know there's a way to get references to recently inspected items (eg $0
), but this isn't for inspected items...
Right click on the console log output provides the option "Store as Global Variable".
Here is a video of it(not created by me).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.