Regardless of having labored on the very complicated Firefox for a variety of years, I will all the time love plain outdated console.log
debugging. Logging can present an audit path as occasions occur and textual content you possibly can share with others. Do you know that chrome supplies monitorEvents
and monitor
so as to get a log every time an occasion happens or operate is known as?
Monitor Occasions
Cross a component and a collection of occasions to monitorEvents
to get a console log when the occasion occurs:
// Monitor any clicks inside the window monitorEvents(window, 'click on') // Monitor for keyup and keydown occasions on the physique monitorEvents(doc.physique, ['keyup', 'keydown'])
You possibly can cross an array of occasions to pay attention for a number of occasions. The logged occasion
represents the identical occasion you’d see in the event you manually known as addEventListener
.
Monitor Operate Calls
The monitor
methodology means that you can pay attention for calls on a selected operate:
// Outline a pattern operate operate myFn() { } // Monitor it monitor(myFn) // Utilization 1: Fundamental name myFn() // operate myFn known as // Utilization 2: Arguments myFn(1) // operate myFn known as with arguments: 1
I actually like which you could the arguments supplied, which is nice for inspecting.
I often go for logpoints as a substitute of embedding console
statements in code, however monitor
and monitorEvents
present an alternative choice to each.
Ship Textual content Messages with PHP
Youngsters lately, I inform ya. All they care about is the expertise. The video video games. The bottled water. Oh, and the texting, all the time the texting. Again in my day, all we had was…OK, I had all of these items too. However I nonetheless do not get…
5 Extra HTML5 APIs You Didn’t Know Existed
The HTML5 revolution has supplied us some superior JavaScript and HTML APIs. Some are APIs we knew we have wanted for years, others are innovative cellular and desktop helpers. No matter API power or function, something to assist us higher do our job is a…
Add Web site Screenshots for Exterior Hyperlinks Utilizing MooTools Tooltips
Earlier than you ship your consumer to an unknown exterior web site, why not present them a screenshot of the location by way of a tooltip so they could preview the upcoming web page? This is how you are able to do simply that utilizing MooTools. The MooTools JavaScript Step one is to seize…
Construct a Calendar Utilizing PHP, XHTML, and CSS
One of many web site options my clients like to supplier their net customers is a web-based dynamic calendar. A web based calendar can be utilized for occasions, upcoming product specials, memos, and anything you possibly can consider. I’ve taken a while to fully…