javascript literal initialisation loop
- by graham.reeds
I have an object which has several properties that are set when the object is created.
This object recently changed to object literal notation, but I've hit a bit of a problem that searching on the net doesn't reveal.
Simply stated I need to do this:
Star = function(_id, _x, _y, _n, _o, _im, _c, _b, _links) {
    var self = {
        id: _id,
        // other properties
        links: [],
        for (var i=0,j=0;i<8;i++) { //<- doesn't like this line
            var k = parseInt(_links[i]);
            if (k > 0) {
                this.links[j++] = k;
            }
        },
        // other methods
    };
    return self;
};
How do I initialise a property in the constructor in object literal notation?