Equivalent of object using literal notation

Posted by brz dot net on Stack Overflow See other posts from Stack Overflow or by brz dot net
Published on 2010-05-28T08:50:58Z Indexed on 2010/05/28 10:01 UTC
Read the original article Hit count: 184

Filed under:
|

See following class:

function availItem(xs, s, m, l, xl) {
            this.xs = xs;
            this.s = s;
            this.m = m;
            this.l = l;
            this.xl = xl;
        }

How can I declare the above class using JSON? I think It should be in following manner but problem is to pass argument.

var availItem = { 
               xs : xs,
                s : s,
                m : m,
                l : l,
                xl : xl


}

I want to use both in same manner like

var obj =new availItem(xs,s,b,l,xl);

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about objects