Some Basic Data Types and Data Structures

Data Types

Most interactions with browsers require us to validate either string or integer data. Both these can be stored in regular javascript variables.

Data Structures

Since we work with web UIs, Sahi's need for data structures is fairly minimal. The few that are used are:

Single dimensional array

var $ar = ["Ram", "Sam", "Jam"];
var $firstUser = $ar[0]; // returns "Ram"


Two dimensional array

var $ar2d = [["Ram",18], ["Sam",20], ["Jam",25]];
var $firstRow = $ar2d[0]; // returns ["Ram",18]
var $firstUser = $firstRow[0] // returns "Ram"
// or
var $firstUser = $ar2d[0][0] // returns "Ram"


Associative Array

var $userInfo = {"name":"Ram", "age":"18"};
var $userName = $userInfo["name"];
var $userAge = $userInfo["age"];