Search code examples
javascriptprototype-programming

Creating an Object(class) structure in Javascript


I am trying to create a Javascript application which displays initially Countries information, Selecting a country all the Regions will be displayed and Selecting a Region all the related Cities will be displayed and at the end by selecting a City Hotels list in that city will be displayed.

Fron Country to City all the informations are lomost same. like

id
name
goedata
etc..

What will be the best way to design the HotelLocator application.

I am interested in using some kind of classes for that.


Solution

  • I think that you need to create a dictionary that will contains all regions each region as value will hold dictionary with all cities and hotels . So when region is selected you will retrieve dictionary with all cities . Each city will hold all hotels .

    It will be a dictionary which as value holds dictionary . Actually it's designed for json . You don't need to create a class . Every array in JavaScript is a dictionary.