HTML and CSS Reference
In-Depth Information
Feature detection—self testing code—was explored as an alternative to browser
sniffing, and we have seen examples of testing both native and host objects and meth-
ods, as well prodding for supported events and CSS properties and even supported
CSS values.
Feature detection is an art, and it is not an easy one to master. Fully mastering
feature detection requires knowledge and experience as well as good judgment.
Rarely is there a single answer, so we must apply our best sense and always be on
the lookout for better ways to harden our scripts. Even though feature detection
is well fit to create scripts with the widest possible support surface, it need not be
used for that purpose. The main motivation when producing scripts for the general
web should stay on avoiding broken web pages, and feature detection can help in
this regard by aborting scripts that are unlikely to succeed.
This chapter concludes our selective tour of the JavaScript language. In Part III,
Real-World Test-Driven Development in JavaScript, we will use test-driven devel-
opment to work through five small projects that combined produce a small chat
application implemented entirely in JavaScript.
 
Search WWH ::




Custom Search