Hi,
The initializer is called "initialize", not "initialization" (see the
docs[1]). Your code throwing the exception isn't being called, hence
the exception not being thrown. If you use the correct name, the
exception is thrown and correctly propagates out to the code creating
the object.
[1]
http://api.prototypejs.org/language/class.html
HTH,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com
On Nov 6, 4:23 pm, Ilya Furman <
smashl...@gmail.com> wrote:
> Hello!
>
> I'm wondering, why class instance is being created while
> initialization method throws an error?
>
> var C = Class.create({
> initialization : function() {
> throw new Error('Hey, you can\'t have any instances of this
> class!')
> },
> foo : 'foofoo' ,
> bar : function() {
> alert(this.foo)
> }
>
> });
>
> var c = new C();
> c.bar();
>
> Demo linkhttp://
jsbin.com/inoqi