最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Can I add properties to an object in the Chrome debugger? - Stack Overflow

programmeradmin0浏览0评论

I know I can edit values or properties on an object in the Chrome debugger, but is there a way to add properties?

Edit: Here's an example of what I mean. In this popup window I can edit that values of these properties on this object. Is there a way I can add new properties to this object?

I know I can edit values or properties on an object in the Chrome debugger, but is there a way to add properties?

Edit: Here's an example of what I mean. In this popup window I can edit that values of these properties on this object. Is there a way I can add new properties to this object?

Share Improve this question edited Aug 11, 2015 at 16:49 Anthony asked Aug 11, 2015 at 16:35 AnthonyAnthony 1,8472 gold badges18 silver badges30 bronze badges 4
  • 1 You mean like: var obj = {}; [Enter] obj.prop = 1;? – Mike Cluck Commented Aug 11, 2015 at 16:39
  • Kind of. I mean when I'm debugging a javascript file and Chrome hits a break point. When you hover over an object a small window appears and you can change the values of the properties of that object in that window. Is there a way to add another property to that object? – Anthony Commented Aug 11, 2015 at 16:45
  • 2 $scope.thing = "that"; [Enter] – Lee Taylor Commented Aug 11, 2015 at 16:51
  • Wow, that worked! I'm surprised I didn't know that. I suppose that is the answer to my question. – Anthony Commented Aug 11, 2015 at 16:53
Add a ment  | 

1 Answer 1

Reset to default 6

For the example in your image, if you were stopped in debugging mode all you would have to do is enter something like $scope.newProp = 'value'; into the console. The object will now have a new property while you continue to debug your program.

发布评论

评论列表(0)

  1. 暂无评论