JavaScript Attributes and Methods
Declaring attributes and methods in JavaScript is different than in PHP. This is because all JavaScript objects are handled as associative arrays or in other words as key/value pairs. There are several ways of setting up a JavaScript associative array. Two of these ways are the use of the traditional array operator [], anotherArray[‘first’] = ‘bob’;, and the use of the dot operator, an Array.second = ‘fred’;. Notice in the following example that the anArray object is initialized as an object using the new operator. If the array operator [] is used to build the key/value pairs, the key is placed within the operator as in the following example with the anotherArray array. If the dot operator is used, the key is ...
Get Oracle Database Ajax & PHP Web Application Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.