Some Basic Data Types and Data Structures
Data Types
Section titled “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
Section titled “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
Section titled “Single dimensional array”var $ar = ["Ram", "Sam", "Jam"];var $firstUser = $ar[0]; // returns "Ram"Two dimensional array
Section titled “Two dimensional array”var $ar2d = [["Ram",18], ["Sam",20], ["Jam",25]];var $firstRow = $ar2d[0]; // returns ["Ram",18]var $firstUser = $firstRow[0] // returns "Ram"// orvar $firstUser = $ar2d[0][0] // returns "Ram"Associative Array
Section titled “Associative Array”var $userInfo = {"name":"Ram", "age":"18"};var $userName = $userInfo["name"];var $userAge = $userInfo["age"];
