Create JavaScript Structures and Objects

JavaScript allows you to put together code lines to create functions and variables to create arrays. You can put functions and variables together to create objects.























ElementDescription
function fnName(parameters) {class="code">

//code

} // end function
Defines a function named fnName and
sends it parameters. All code inside function will execute when the
function is called.
var myArray = new Array("a",
"b", "c");
Creates an array. Elements can be any type (even mixed
types).
Var myJSON = {class="code">

"name":
"Andy",


"title":
"Author"


}
Creates a JSON object. Each element
has a name/value pair, and can contain anything, including an array
(with square braces) another JSON object,
or a function.
Var person = new Object();class="code">

Person.name =
"Andy";
Creates an object. You can add ordinary variables (which become
properties) or functions (which become methods).








dummies

Source:http://www.dummies.com/how-to/content/create-javascript-structures-and-objects.html

No comments:

Post a Comment