HTML and CSS Reference
In-Depth Information
3. Is an expression that evaluates to the value 0 true or false? How about the string
“false” inside quotation marks?
4. How do you make sure that a variable you create in a function is only visible
locally in that function?
5. How are functions different from methods?
Quiz Answers
1. To accommodate the inclusion of JavaScript programs in a normal HTML docu-
ment, Netscape introduced the <script> tag. By placing a <script> tag in a docu-
ment, you tell the web browser to treat any lines of text inside the tag as script
rather than as content for the web page.
2. Events are special actions triggered by things happening in the system (windows
opening, pages being loaded, forms being submitted) or by reader input (text being
entered, links being followed, check boxes being selected). Using JavaScript, you
can perform different operations in response to these events.
3. The number 0 is false, and the string “false” is true. The only false values are 0 ,
null , an empty string, undefined , NaN (not a number), and the Boolean value
false .
4. The var statement is used to define a local variable inside a function.
5. Methods are associated with a specific object, and functions are standalone rou-
tines that operate outside the bounds of an object.
Exercises
1. If you haven't done so already, take a few minutes to explore the documentation
for JavaScript at https://developer.mozilla.org/en/JavaScript. See whether you can
find out what enhancements were included in the latest version of JavaScript that
weren't included in earlier versions.
2. Find a simple JavaScript script somewhere on the Web—either in use in a web
page or in an archive of scripts. Look at the source code and see whether you can
decode its logic and how it works.
 
Search WWH ::




Custom Search