JavaScript Guide | Part 3

JavaScript Guide | Part 3

JavaScript Language Elements — Variables

Variables are generally dynamically typed. The variables are defined simply by assigning them a value or using the command var. Variables declared outside any function are visible in the “global”, accessible by the entire web page, the variables declared inside a function are local to that function. To pass variables from one page to another, a developer can set a cookie, or use a hidden frame or window in the background to store.

JavaScript Objects

Everything in JavaScript is either a primitive value or object. Objects are entities with unique (they are equal only to themselves) and associated property names to values. This means that an object is an associative array similar to the hash in Perl and Ruby, or Python dictionaries, PostScript, and Smalltalk.

JavaScript has several kinds of predefined objects, including arrays (vectors), Boolean (boolean) Date (objects-containing a date and time), Function (functions), Math (object containing functions used in math), Number (numbers), Object (objects), the RegExp (regular expressions) and String (strings). Other objects are “objects guests”, defined not by language but on the execution. In a browser, the typical host objects belong to the DOM: window (window), form (form), links (links) etc.

Defining a constructor, you can define objects. JavaScript is an object-oriented language based on prototypes. This means that inheritance is between objects, not between classes (JavaScript has no classes). Objects inherit properties from their prototypes.

You can add additional properties or methods to individual objects after they are created. To do this for all instances created from a single manufacturer, you can use the prototype property of the manufacturer to access the object prototype.

Default JavaScript Objects

Besides allowing the definition of objects, JavaScript provides a number of objects that can be used for your scripts:

Anchor
Applet
Area
Array
Base
BASEFONT
Body
Button
Checkbox
Date
Document
Event
File
FileUpload
Forms
Frame
Frameset
Function
Hidden
History
Iframes
Image
Layer
Links
Location
Math
Meta
Navigator
Number
Object
Option
Password
Radio
RegExp
Reset
Screen
Select
Style
String
Submit
Table
TableData
TableHeader
TableRow
Text
Textarea
Window

JavaScript Data Structures

A typical data structure is the array or vector, that is a map between integers and values. In JavaScript, all objects can associate integers and values, but the carriers are a special kind of objects that have behaviors extra and specialized methods in integer indexes (e.g., Join, slice, and push).

Carriers have a length property that is guaranteed to be increasingly used in the index’s largest carrier. It is automatically updated if you create a property with an index even higher. Write a smaller number in the length property removes the largest index. This property is the only special feature of the carriers, which distinguishes them from other objects.

Study: From Wikipedia, the free encyclopedia. The text is available under the Creative Commons.

Sharing

Leave your comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.