Site hosted by Angelfire.com: Build your free website today!

JavaScript Labs

Annette Mayville
Dr. Johari
Advanced Web Communication and Design

In the Lab, Mini Project 2

Instruction: In a Composer page answer the following questions (pages 7-12).

0.  Define Object, Properties, Method, and Handling Events.

Object: In JavaScript, an object is a window, a form, or an element of the form such as buttons and checkboxes.

Properties: In JavaScript, an object has properties, for example a window has a title and a form has checkboxes. A title on a window or checkboxes on a form can be modified, and also can be objects themselves which are called sub-objects.

Method: In JavaScript, the things that objects can do are called methods, for example buttons click, and windows open. The objects are often followed by parentheses which signal a referral to a method rather than a property.

Handling Events: In JavaScript, users who visit a webpage are performing an event, for example summiting a form. Event handlers are commands that deal with events.

1. A value is _____________________________. a piece of information

2. A word (or words) enclosed in quotes is  _______________ value. string

3. A word (or words) _______________ value. can be a

4. Variables contain ___________. values

5. Circle the value part of the following statement:  myName = “Steve” Steve

6. Circle the variable(s) part(s) of the following assignment statement: x = x + 1 x

7. Which of the following can be a variable: doghouse, DogHouse, dog House, dogHouse All words can be a variable except dog House which contains a space. A variable cannot have spaces or punctuation, and also, a variable cannot start with a digit.

8. Which of the following can be a variable: javaClass, sum, Math, Date, document, pepsi The only word that can be used as a variable is pepsi. The other words are JavaScript reserved words.

9. What are the operators in JavaScript? Symbols which are used to work with variables are called operators. The symbols include the +, -, *, /, %, ++, and -- symbols.

10. What does the following operator do to the values of the variables? X * Y The x and y are multiplied together.

11. If x is 5, “y=x- - “ results in y set to ---- and x set to ----. y is set to 5 and x is set to 4.

12. “cat” = 1, then the “cat” + 5 results in:  “cat5” or 6. The result will be 6.

13. What is assigning a variable? Assigning a variable is when there is a value placed into a variable.

14. Is the assignment x/y means x = x %y? I don’t find the assignment x/y in the Assignments table on page 11, so I conclude this maybe a typing error. Possibly the assignment was meant to be x/=y then this will mean the same as x=x/y.

15. What does the assignment x* =2 mean? Assignment x*=2 is the same as x=x*2.

16. What does the following comparison statement indicates? todayDate = = “Tuesday” The value is comparing if the current date (todayDate) is actually Tuesday.

17. JavaScript is just a plain ___ file with the extension _____ or  _____. text, html, htm