Special statement
This article is a series by Tomek Sułkowski published on Medium. According to the author revealed a total of 24 articles, updated until December 24, the copyright of the original author.
The author recommended our Chinese translation on Twitter, screenshot at the end
The translator had already communicated with the author before the translation to get permission to translate the whole series. In order not to disturb your reading, the record of authorization is here
The body of the
In the 24 days leading up to the holiday season, I will be Posting a series of short posts on how to use development tools in a more interesting way. Yesterday we looked at conditional breakpoints and “Ninja Logs”.
35. queryObjects function
Object query method
Let’s say we have a piece of code that looks like this, and we define some objects in it.
So what objects exist at a particular time, in a particular execution context?
DevTools has a queryObjects function that shows us this.
Note that the last object created in the list is not available: because no reference to it survives after the code executes, we now have only three Person objects:
36. monitor functions
Mirror function
Monitor is a DevTools method that lets you spy on any “function calls “: Every time a spIED sneaked method is run, the console prints out its instance, including the function name and the arguments to call it.
Let’s take the Person class from the previous example and extend two methods:
class Person {
constructor(name, role) {
this.name = name;
this.role = role;
}
greet() {
return this.getMessage('greeting');
}
getMessage(type) {
if (type === 'greeting') {
return `Hello, I'm The ${this.name}! `; }}}Copy the code
As you can see, the greet method executes the getMessage method with a special argument. Let’s see what happens if we trace the getMessage method:
This will save us a lot of console.logs!
That’s all for today’s sharing
We noticed that,
Routine: If you learn something new from this
→ Follow me on Twitter: Tomek Sułkowski
Other series
Other articles in this series will be translated soon, with links posted here.
- Day 1: ‘$’ in the Console
- Tips you might not know about Chrome debugging tools Day 2: Copying & Saving
- Chrome debugging tools you didn’t know about
- The Chrome debugging tool has a few tricks you don’t know about.
- Day 5: Console log, puzzling case
- You don’t know the Command menu for Chrome
- 7. Fun tips you didn’t know about the Chrome Debugging Tool Consle
- Chrome’s Color picker is a Color picker that you don’t know about.
- Day 9: Time console
- Custom Formatters are custom formatters for Chrome.
- Today: Style Editors continued
- Tips you don’t know about the Chrome Debug Tool Day 12: Ninja Log Print! (the ninja logs)
- Chrome debugging Tool tips you didn’t know about
- Chrome Debugging Tool tips you didn’t know About day 14: Other shortcuts
- Chrome debugger tips you didn’t know about
- Tips you don’t know about Chrome debugging Tools 16: Breakpoints
- Day 17: Farewell to Console
- What you Didn’t know about Chrome Debug Tools
- Chrome debug tool tips you don’t know
- Tips you didn’t know about Chrome debugging tools Day 20: The dark arts of Workspace
- Tips you Don’t Know about Chrome Debugging Tools Day 21: Snippets
- Chrome Debugging Tool tips you didn’t know
- Chrome debug Tool tips you don’t know
- Day 24: The last day, New Year’s Day, is awesome
Write in the last
If you are sure of my translation, you can also pay attention to my wave oh ~ incidentally my open source project, for a wave of star→ see here, beautiful blog system