Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create this object in javascript?

Status
Not open for further replies.

alFRed88NSH

Technical User
Mar 27, 2011
4
MY
I'm writing a script in javascript(actually a chrome extension) and I need an object that I can write to it like this(sorry, don't know how to explain it better) and then I convert it to string with format of json.

id[3].weekDay[6].hour[2] = 0

The id indices are unlimited, for weekDay 7 and hour 24.

I searched in google but i couldn't find what I wanted. Actually don't know the best keyword to search.(objects in arrays?)
 
More information(forgot to write these, and I don't know how to edit my posts, sorry):
I don't know what exactly it is called, but I can write it's declaration in VB.NET if that helps you.
Here, id is an array, that each element in it contain another array(weeksDay) and in that array each contain another array(hour)
 
Hi

JavaScript:
[gray]// in a single step[/gray]
id[teal]=[[/teal] undefined[teal],[/teal] undefined[teal],[/teal] undefined[teal],[/teal] [teal]{[/teal] weekDay[teal]:[/teal] [teal][[/teal] undefined[teal],[/teal] undefined[teal],[/teal] undefined[teal],[/teal] undefined[teal],[/teal] undefined[teal],[/teal] undefined[teal],[/teal] [teal]{[/teal] hour[teal]:[/teal] [teal][[/teal] undefined[teal],[/teal] undefined[teal],[/teal] [purple]0[/purple] [teal]][/teal] [teal]}[/teal] [teal]][/teal] [teal]}[/teal] [teal]][/teal]

[gray]// step by step[/gray]
id[teal]=[][/teal]
id[teal][[/teal][purple]3[/purple][teal]]=[/teal][teal]{}[/teal]
id[teal][[/teal][purple]3[/purple][teal]].[/teal]weekDay[teal]=[][/teal]
id[teal][[/teal][purple]3[/purple][teal]].[/teal]weekDay[teal][[/teal][purple]6[/purple][teal]]=[/teal][teal]{}[/teal]
id[teal][[/teal][purple]3[/purple][teal]].[/teal]weekDay[teal][[/teal][purple]6[/purple][teal]].[/teal]hour[teal]=[][/teal]
id[teal][[/teal][purple]3[/purple][teal]].[/teal]weekDay[teal][[/teal][purple]6[/purple][teal]].[/teal]hour[teal][[/teal][purple]2[/purple][teal]]=[/teal][purple]0[/purple]
If this is not what you want, you will have to give us more details.
Or try asking in forum1766 .


Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top