Tuesday, June 30, 2015

JavaScript Objects

 object ⇔ {prop1, prop2, prop3, ... , propN}, (property ⇔ name:value)

A JavaScript object is a collection of properties, each of which has a name and a value. Since property names are strings, we say that an object maps string to values. In computer science, a data structure mapping string to values is named "hash", "hashmap", "hashtable", "dictionary" or "associative array". JavaScript objects are dynamic, as properties can be added and deleted after the object creation.

JavaScript object properties

An object property associates a name to a value. A property name may be any string. The property value may be any JavaScript value: a primitive value, an object, a function or (in ECMAScript5) a getter or a setter function.

Saturday, June 6, 2015

JavaScript Operators

1. Arithmetic Operators

1.1 Basic Arithmetic Operators
The basic arithmetic operators are * (multiplication), / (division), % (modulo: remainder after division), + (addition), and - (subtraction).
division operator
JavaScript do not have integer, all numbers are floating-point. So division operations have floating-point results:
5/2 // 2.5 not 2.
addition operator
The addition operator adds numeric operands or concatenates string operands.
19  +  84  // 103   two numbers -> addition
"19" + "84" // "1984" two strings -> concatenation
In other cases the conversion which takes place gives priority to string concatenation: if either operand is a string or an object that convert to string, the other operand is converted to string and a concatenation is performed.