keywords:
Bookmark and Share



Front Back
What is an Event?
An action that occurs within a Web browser or Web document.
What is a Date Object?
To work with dates JavaScript supports a date object which contains informtion about a specified date and time. The date object stores a numeric value that is equal to the number of milliseconds(1/1000 of a second) between the specified date and time and January 1, 1970.
What are Date Methods?
They are methods that can be used to retrieve information from a date object or to change a date object's value.
What is an Event Handler?
An event handler is an attribute added to an element that instructs Web browsers to run a script command or commands when an event (such as a mouse click) occurs within the element.
What attribute would you add to a button element to run the showlmage() function when the button is clicked?
onclick = "showlmage()"
What HTML code creates a link that runs the showlmage() function when the link is clicked?
What JavaScript command creates a variable named examDate storing the following date and time: May 8, 2011 at 6:55:28 p.m.?
var examDate = new Date("May 8, 2011 18:55:28");
What command extracts the month value from the examDate variable?
var examDate = new Date("May 8, 2011 18:55:28");
What value would be returned by this method?
examDate.getMonth() // The value returned would be 4.
What command extracts the four-digit year value from the examDate variable?
var examDate = new Date("May 8, 2011 18:55:28");
examDate. getFull Year ()
What command changes the day of the month value in the exam Date variable from 8 to 9 (while leaving all of the other date and time values unchanged)?
var examDate = new Date("May 8, 2011 18:55:28");
examDate.setDate(9);
What command creates a variable named currentTime that stores the current date and time?
currentTime = new Date () ;
How do you use a unary operator to increase the value of the thisMonth variable by 1?
thisMonth++
How do you use an assignment operator to increase the value of the thisMonth variable by 1?
thisMonth += 1;
What command rounds the value of the thisMonth variable to the nearest integer?
Math.round(thisMonth)
What conditional operator changes the value of the thisMonth variable to 12 if it equals 11 but otherwise leaves the value unchanged?
thisMonth = (thisMonth == 11) ? 12 : thisMonth;
What function tests whether the value of the thisMonth variable is a number?
IsNan(thisMonth)
What command displays the value of the thisDay variable with no decimal places?
thisDay. toFixed (0) ;
What statement runs the function calcMonth() after a 0.5-second delay?
setTimeout("calcMonth", 500);
What statement runs the function calcMonth() every 0.5 seconds?
set Interval ("calcMonth", 500);
What is an Operator?
An Operator is a symbol used to act upon an item or a variable within a JavaScript expression.
What is an Operand?
The variables or expressions that operators act upon are called operands.
What are Arithmetic operators?
Operators that perform simple mathematical calculations. Also called binary operators. Examples: "+" combines or adds two items, "-" subtracts one item from another, "*" multiplies two items, "/" divides one item by another, "%" calculates the remainder after dividing one value by another.
What is an Binary Operator?
Arithmetic operators that work with two operands in an expression.
What are Unary Operators?
Operator that works only on one operand. They can make code more compact and efficient.
What is an Increment Operator?
One of the Unary operators, it increases the value of the operand by 1. Its indicated by the ++ symbol. Example x++, Equivalent to x = x+1
What is an Decrement Operator?
One of the Unary operators, it decreases the value of the operand by 1. Its indicated by the -- symbol. Example x--, Equivalent to x = x-1
What are Negation Operators?
Changes the sign of (or negates) an item's value. Indicated by the - symbol. Example -x, Equivalent to x = 0 - x
What are Assignment Operators?
An operator used to assign value to an item. The most common assignment operator is the equal sign (=), which assigns the value of one expression to another.
What is the Math object?
It is an object that can be used for performing mathematical tasks and storing mathematical values.
What are Math Methods?
Supported by the Math Object , used to store functions used for performing advanced calculations and mathematical operations such as generating random numbers, extracting square roots. The syntax for applying a Math method is "Math.method(expression)".
How to use the function:
value.toFixed(n)
To display a numeric value to a set number of digits. Where value is the numeric value and n is the number of digits to the right of the decimal place to be displayed. The toFixed() method converts the numeric value to a text string. Example: testValue= 2.835; - testValue.toFixed(1) // returns "2.8"
How to use the function:
parselnt(string)
To extract an integer from the beginning of a text string, where string is a text string that starts with an integer value. Example: parseInt("206.58 lbs") // returns 206
How to use:
parseFloat(string)
To extract a numeric value from the beginning of a text string, where string is a text string that starts with a numeric value. Example: parseFloat("206.58 lbs") // returns 206.58
How to use:
isNaN(value)
To test whether a value represents a number, where value can be either a text string, a numeric value, or another data type. The isNaN() function returns the Boolean value true if value is not a number, and false if it is.
What is a Conditional Operator?
It is a ternary operator that tests whether a certain condition is true or not. If the condition is true, one value is returned; if the condition is not true, a different value is returned. Syntax: (condition) ? trueValue : falseValue
What is a Comparison Operator?
Used to create expressions that have a true or false value. It is an operatot that compares the value of one expression to another.
values are equal.x==y
values are not equal. x!=y
values greater than. x>y
values less than. x<y
values greater than or equal. x>=y
values less than or equal. x<=y
x of y cards