Basic Typesvar intValue = 1;
var floatValue = 3.0;
var stringValue = "This is a string\n";
var sqString = 'This is also a string';
Javascript is a dynamically typed language. Variables are declared with the keyword var. Common simple types are supported. Arraysvar emptyList = [];
var homogenousList = [1, 2, 3];
var heterogenousList = ["one", 2, 3.0];
Javascript has built-in collection objects. The Array object is a dynamically typed sequence of Javascript values. They are created with the bracket notation [] or with the new operator on the Array object (e.g. new Array(5)). Property Mapsvar emptyMap = {};
var homogenousMap = {"one": 1, "two": 2, "three": 3};
var heterogenousMap = {"one": 1,
"two": "two",
"three": 3.0};
Along with Arrays are the Object objects. They act as property maps with strings serving as keys to dynamically typed data.Access// Dot notation property access
window.alert("Homogenous map property \"one\" "
+ homogenousMap.one);
// Subscript notation property access
window.alert("Homogenous map property \"two\" "
+ homogenousMap["two"]);AssignmenthomogenousMap["one"] = 10;
homogenousMap.two = 20;
Removaldelete homogenousMap["one"];
delete homogenousMap.two; Iterationfor (var key in heterogenousMap) {
window.alert("Heterogenous map property \""
+ key
+ "\" = "
+ heterogenousMap[key]);
}Functionsvar callable = function (message) { // <-- notice assignment
window.alert("Callable called with message = "
+ message);
}Read more: Javascript
var floatValue = 3.0;
var stringValue = "This is a string\n";
var sqString = 'This is also a string';
Javascript is a dynamically typed language. Variables are declared with the keyword var. Common simple types are supported. Arraysvar emptyList = [];
var homogenousList = [1, 2, 3];
var heterogenousList = ["one", 2, 3.0];
Javascript has built-in collection objects. The Array object is a dynamically typed sequence of Javascript values. They are created with the bracket notation [] or with the new operator on the Array object (e.g. new Array(5)). Property Mapsvar emptyMap = {};
var homogenousMap = {"one": 1, "two": 2, "three": 3};
var heterogenousMap = {"one": 1,
"two": "two",
"three": 3.0};
Along with Arrays are the Object objects. They act as property maps with strings serving as keys to dynamically typed data.Access// Dot notation property access
window.alert("Homogenous map property \"one\" "
+ homogenousMap.one);
// Subscript notation property access
window.alert("Homogenous map property \"two\" "
+ homogenousMap["two"]);AssignmenthomogenousMap["one"] = 10;
homogenousMap.two = 20;
Removaldelete homogenousMap["one"];
delete homogenousMap.two; Iterationfor (var key in heterogenousMap) {
window.alert("Heterogenous map property \""
+ key
+ "\" = "
+ heterogenousMap[key]);
}Functionsvar callable = function (message) { // <-- notice assignment
window.alert("Callable called with message = "
+ message);
}Read more: Javascript
0 comments:
Post a Comment