简体   繁体   English

Chrome Javascript控制台 - 使用console.log(obj)引用对象输出?

[英]Chrome Javascript Console - Reference to object output with console.log(obj)?

Is there a way to get a javascript reference to an object that was output to the chrome console? 有没有办法获得一个javascript引用输出到chrome控制台的对象?

For example, say I had the following javascript: 例如,假设我有以下javascript:

top.it = {hi:'there'};
console.log(top.it);

This would output to the chrome console as 这将输出到chrome控制台

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 ? 有没有办法获得对使用console.log输出的对象的引用?

I know there's a way to get references to recently inspected items (eg $0 ), but this isn't for inspected items... 我知道有一种方法可以获得对最近检查过的物品的参考(例如$0 ),但这不适用于检查过的物品......

Right click on the console log output provides the option "Store as Global Variable". 右键单击控制台日志输出,提供“存储为全局变量”选项。

Here is a video of it(not created by me). 是它的视频(不是由我创建的)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM