I have an object parameter and it has a property value. it is thusly defined
var parameter = {
value : function() {
//do stuff
}
};
my problem is that, in some cases, value needs to have a property of its own named length
can i do that? it seems that putting this.length = foo does not work, neither does parameter.value.length = foo after the object declaration.
The problem seems to be with the selection of the word 'length'. In JavaScript, functions are objects and can have properties. All functions already have a length property which returns the number of parameters the function is declared with. This code works:
var parameter = {
value : function() {
//do stuff
}
};
parameter.value.otherLength = 3;
alert(parameter.value.otherLength);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With