Class 05 Flashcards
Scripting language which is used to enhance the
functionality and appearance of web pages.
Javascript
indicates to the browser that the following text is a part of a script
script tag
write into an HTML document
innerHTML
write into HTML output box
document.write()
write into an alert box
window.alert()
write into the browsers console
console.log()
Gives you the ability to generate part or all of a web page’s content at the time it is shown to the user
Scripting
Used to declare the names of variables
var
A single-line comment begins with the characters
//
Multiline comments begin with delimiter
/* hello
world
!!!
*/
• A variable is assigned a value with an …
assignment operator (=)
Signifies that a variable has no value
null keyword
converts its string argument to an integer
parseInt
error that occurs at execution time.
logical error
an error that causes a script to fail and terminate prematurely.
fatal logical error
an error that allows a script to continue executing, but the script produces incorrect results
nonfatal logical error
skips the remaining statements in the body of the statement and proceeds with the next iteration of the loop
• In while and do…while statements, the loop-continuation test evaluates immediately after the continue statement
executes
• In for statements, the increment expression executes, then the loop-continuation test evaluates
continue statement in while, for, and do-while
operator is used to ensure that two conditions are both true before
choosing a certain path of execution
the && operator (AND)
reverses the meaning of a condition (i.e., a true
value becomes false, and a false value
becomes true)
• Has only a single condition as an operand (i.e.,
it is a unary operator)
• Placed before a condition to evaluate to true if
the original condition (without the logical
negation operator) is false
!(condition) logical negation
passes information from inside a function back to the point in the program where it was called
return statement
a programmer-defined function that is used to determine and
return the largest of three floating-point values.
maximum
Method that rounds its argument down to the closest integer
Math.floor
Random number generation
Math.random()
a standard object model and programming interface for
HTML.
HTML DOM
a standard for how to get, change, add, or
delete HTML elements.
HTML DOM
is an API that allows programs to
interact with HTML (or XML) documents
Document Object Model
JavaScript programs access the DOM through a host object named
document
gives you scripting access to all the elements on a web
page.
DOM
modern browsers have implemented (almost) the same methods and
properties for JavaScript interactivity, it is often referred to
Browser Object Model (BOM)
window.location.href RETURNS?
href, URL of the current page
window.location.hostname RETURNS?
domain name of the web host
window.location.pathname RETURNS?
path and file name of the current page
window.location.protocol RETURNS?
protocol used
eg (http:// or https://)
window.location.assign() RETURNS?
loads a new page