The fastest and easiest way to change my Jason, including the data of objects, Along with actual objects connected?
For example, I get data for an array of fruits for the forfeil, which in turn has an array of seeds:
< P> It is all good and good, but on the customer we do stuff with this fruit, like eat it and plant trees ... ... fruits (name, color, seeds) {this.name = Name this.color = color this.seeds = seeds this.eat = function () {// munch munch}} function seeds (size, density) {this.sensity = size this.density = density this.plant = function () {// grow grow}}
Currently the daily routine of success of my AJAX is talking and every object is made alternately and it does not handle seeds yet, Because before I looping on seed constructors, I am thinking
Is not there any better way?
Success: function (data) {FOLBOL. Length = 0 $ .eight (data.) Fortboiled, function (I, F) {Falboole Pius (new fruit (F.name, F. colore, F.seeds)})
I have not searched looping on objects because they are all the ways, will it work?
Yes, this will work, but it is not desirable. In addition to appearing a little Hami IMO, you are applying the methods of each example of your fruit and seed, where you should use the prototype series. If you are using instanceof
in the future, then this method will not work anyway.
What you are currently doing is the best solution; And you will be able to use instanceof
.
If you are feeling adventurous, you look like a JSONP response using JSONP instead of ajax:
new fruit ("orange", "blue", [new seed ( New seeds ("big", "soft"), new fruits ("banana", "yellow", [new seeds ("small", "hard"), new seeds (" Big "," soft "))))); which will save you to loosen all your objects, and how you will get your fruits and seeds (and instanceof
support); Although I still have to stay what you are up to.
Make your bananas look the best.
Comments
Post a Comment