Lab 10: JavaScript Data Types

In this lab, you will work with JavaScript datatypes.

Objectives:

Part 1: JavaScript Datatypes

Steps:

  1. Use File - Close All to close all open editing windows.

  2. In RAD, create a new Dynamic Web Project named Lab10Web associated with Lab10EAR:

    1. From the menu, choose File - New Dynamic Web Project to start the wizard.

    2. For the Project name, enter Lab10Web.

      Ensure that the Add project to an EAR checkbox is selected, then for the EAR project name, enter Lab10EAR.

      Press Finish. You can close any Technology Quickstart window.

    3. Expand the Lab10Web project and note the WebContent folder - that's where you put your HTML, JavaScript and CSS files.

  3. In the WebContent folder, create a new HTML File named datatypes.html, and in it, write a script that:

    Test your work.

  4. Create a new HTML File named quote-of-the-day.html. Code this file so it references an external JavaScript file that displays the following as a Javascript alert (not in the page):

    Today's quote is:
    
    "On the Internet, nobody knows you're a dog."       
            

    Define only one variable and be sure to include the blank lines and quotes as shown.

  5. Create a new HTML page named undefined.html and an external Javascript that defines a variable without initializing it and then displays its contents using document.write().

Part 2: More Practice

Steps:

  1. Create a HTML file named variables.html that references an external Javascript. In the script, do the following:

    - declare a variable named z initialized
      to "abc"
    - print z
    - redeclare z and initialize to -876.554
    - print z
    - print a nonexistent variable q        
            

    Run and test, and use the JavaScript Console to see any error messages.

  2. Create a new HTML file named equalityoperators.html and an external Javascript that demonstrates the difference between the == and === operators, perhaps using the examples in the Data Types chapter as inspiration.