Array JavaScript

Criando como objeto:

var estados = new Array();
estados[0] = new Array("RS","PR","SC");
estados[1] = new Array("SP","RJ","ES","MG");
estados[2] = new Array("BA","PE","CE","RN","RR","MA","PB","AL","SE");
estados[3] = new Array("MT","MS","GO","DF");
estados[4] = new Array("RR","AP","AM","PA","RO","AC","TO");
Com sintaxe literal:
var estados = [
["RS","PR","SC"],
["SP","RJ","ES","MG"],
["BA","PE","CE","RN","RR","MA","PB","AL","SE"],
["MT","MS","GO","DF"],
["RR","AP","AM","PA","RO","AC","TO"]
];
Associativo:
var estados = {
sul: "RS, PR, SC",
sudeste: "SP, RJ, ES, MG",
nordeste: "BA, PE, CE, RN, RR, MA, PB, AL, SE",
centroOeste: "MT, MS, GO, DF",
norte: "RR, AP, AM, PA, RO, AC, TO"
};

alert(estados.sul); // uma maneira de obter os elementos

Comentar este artigo: