• setInterval(function, interval) - Calls a function repeatedly every timer
period
• setTimeout(function, interval) - Calls a function once after a time period
The time periods are expressed in milliseconds.
Both these functions return a handle which can be used to cancel or stop the firing of events.
passing the handle into the function "clearTimeout(handle)" will cancel the previous timer.
JSON Data representation
In JavaScript source code, JavaScript objects can be declared using the language syntax. This
syntax is surprisingly flexible. When one wants to pass data from one application to another, an
encoding has been defined called "JSON" which is essentially encoding a tree of data into a single
string which looks like the definition of a JavaScript object in source.
JSON within JavaScript
JSON within Java
See also:
• Package – javax.json
Dates and times within JSON
JSON does not provide any native support for date/time encoding. As such, a transmission of a
date/time is commonly performed encoded in a string.
A common format used for this encoding is:
YYYY-MM-DD'T'HH:mm:ss'Z'
for example:
2014-06-20T14:58:32Z
This encoding is known as ISO 8601.
See also:
• Wikipedia – ISO 8601
• Dojo Dates and Times
Debugging in the browser
Since the majority of web execution occurs within the browser itself, we need good tools and
techniques for debugging our code within that environment. Fortunately, all the modern browsers
come supplied with development tools that assist with debugging.
Of the features that are available, some are more important than others. The first I wish to discuss
is the console log. Although this can be used to log your own diagnostics statements, it is also
where the browser itself logs information. If a JavaScript error is encountered during evaluation, it
is within the console log that we will learn this.
The second area that is of importance is are the JavaScript debuggers. We can set breakpoints
within our JavaScript code such that when these breakpoints are encountered during execution, the
debugger will kick in and show us that we have reached the breakpoint. In addition, we can
Page 133
Kommentare zu diesen Handbüchern