I can't find my reference, can somebody tell me if this is correct syntax to define my own objects:
ThxCode:function object(name, id, val) {
this.name = name;
this.id = id;
this.val = val;
return this;
}
var myob = new object('ob1, 1, 43');
Printable View
I can't find my reference, can somebody tell me if this is correct syntax to define my own objects:
ThxCode:function object(name, id, val) {
this.name = name;
this.id = id;
this.val = val;
return this;
}
var myob = new object('ob1, 1, 43');
what troube are you having? the code looks ok to me
CB,
If u want to assign the values to the individual attribute elements u have to pass the arguments in this way. Enclosing all the args within a single quoted expression will be intepreted as the first argument only. Hope this makes sense.
Try:
var myob = new object("ob1", 1, 43);
instead of
var myob = new object('ob1, 1, 43');
- Jemima.
that was a typo, I wanted to know if the return this; was correct
Absolutely!