If you like this, you might also enjoy:
Once you've created the file, add the tags that indicate the document is an HTML document:
Then, add a body tag, which is where you'll place all of the content for a page:
Whenever we want to introduce a script to a part of a page, we
just use a
document.write refers to a procedure that writes
whatever string it receives to the page.
A more annoying way to write a "Hello, World!" program is to use
To see what this page does, click here.
grabs ahold of an object connected to the
p tag with id
innerHTML attribute of this object can be used to change the HTML inside of the tag.
Some consider directly modifying the
innerHTML property to be "bad style." (I don't.)
The proper style would create a new HTML element and insert it:
adds a new HTML element at the end of a tag
document.createTextElement creates a new
plaintext HTML element.
Variables and values
bind a name to a value (like
var name = value ;
One can also change the value of an existing variable by using the assignment (=) operator:
The format for an object literal is to enclose a (comma-separated) sequence of
fieldname : value
entries between curly braces:
To access a property (also known as field, member or attribute) of an
object, one can use the
literal arrays are constructed from the bracket syntax:
Functions can also be recursive:
Functions can also be iterative:
The object literal syntax is only one way to create an object. Here are four ways to create an object with two fields:
There are several ways to access the field of an object:
One can also iterate over the fields of an object using a