If I only need one of something, I go with an object, otherwise if I
need more then one I go with a class-like structure.. though I don't
use Prototypes Class method, so I'll let someone that does answer that
part of the question.
Josh Powell
On May 11, 1:44 pm, louis w louiswa...@gmail.com
Josh could you post an example of how you do it? I am interested in
all of the different approaches.
Thanks.
On May 11, 6:12 pm, Josh Powell seas...@gmail.com wrote:
If I only need one of something, I go with an object, otherwise if I
need more then one I go with a class-like structure..
Louis,
Your error is that you should not be using the new keyword before
Class.create()
Class.create() is a helper function that essentially just returns a
function. Note, in js, all named functions are considered constructors.
Obviously, a function that has no prototype properties and sets not
I do this:
var MyClass = function () {
this.foo = 'bar'
}
MyClass.prototype = {
'baz': function() {
alert('blitz');
}
}
//Which lets me:
var myObj = new MyClass();
myObj.foo; // 'bar'
myObj.baz(); // alerts 'blitz'
//And even:
for (attr in myObj) {
alert(attr); //
On May 11, 6:38 pm, Ryan Gahl ryan.g...@gmail.com wrote:
Louis,
Your error is that you should not be using the new keyword before
Class.create()
Class.create() is a helper function that essentially just returns a
function. Note, in js, all named functions are considered constructors.
They
On May 12, 1:20 pm, RobG rg...@iinet.net.au wrote:
[...]
Javascript can emulate many object models, not just classic OO or
class-based iheritance.
That should have been: many *inheritance* models
--
Rob
--~--~-~--~~~---~--~~
You received this message