I have around 50 objects like:
object[0].one = something;
object[0].two = else;
object[0].options = whatever;
Not sure how to describe it but they each have sub parameters. I was trying to add an additional parameter that I would add manually only to those I wanted too, like so:
object[15].condition = function() { if (something) { then do something; } } ;
//and then later on in a function do
if (this.condition) {
this.condition;
}
but I can't get it to work =( Is something like this possible? Any help is greatly appreciated.
asked Jun 21, 2013 at 0:23
Hate Names
1,6061 gold badge15 silver badges20 bronze badges
1 Answer 1
if (this.condition) {
this.condition();
}
answered Jun 21, 2013 at 0:27
Igor
15.9k1 gold badge29 silver badges34 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-js
object[15]turn intothis?this.condition()instead ofthis.condition.