Javascript Object/Array population question
Posted
by
gnomixa
on Stack Overflow
See other posts from Stack Overflow
or by gnomixa
Published on 2011-01-18T01:39:08Z
Indexed on
2011/01/18
1:53 UTC
Read the original article
Hit count: 462
Is there a difference between:
var samples = {
"TB10152254-001": {
folderno: "TB10152254",
ordno: "001",
startfootage: "",
endfootage: "",
tagout: "Y"
},
"TB10152254-002": {
folderno: "TB10152254",
ordno: "002",
startfootage: "",
endfootage: "",
tagout: "Y"
},
"TB10152254-003": {
folderno: "TB10152254",
ordno: "003",
startfootage: "",
endfootage: "",
tagout: "Y"
}
};
AND
var samples = new Array();
samples["TB10152254-001"] = {
folderno: "TB10152254",
ordno: "001",
startfootage: "",
endfootage: "",
tagout: "Y"};
samples["TB10152254-002"] = {
folderno: "TB10152254",
ordno: "002",
startfootage: "",
endfootage: "",
tagout: "Y"
};
samples["TB10152254-003"] = {
folderno: "TB10152254",
ordno: "003",
startfootage: "",
endfootage: "",
tagout: "Y"
};
EDIT:
I will re-phrase the question: How do I populate the hash dynamically? I can't do something like samples.TB10152254-003 because i TB10152254-003 is dynamic...so, is that even possible?
© Stack Overflow or respective owner