Just seen a factory style object creating in JavaScript (without literals). What else do I need to k

Posted by alex on Stack Overflow See other posts from Stack Overflow or by alex
Published on 2010-05-30T09:39:12Z Indexed on 2010/05/30 9:42 UTC
Read the original article Hit count: 154

Filed under:
|

I have just seen this in code

var thisYear = (new Date()).getFullYear();

See it live on JSbin.

This is cool, as I've always done something like that in 2 lines, i.e. create the new object instance and assigned it to a variable, then called the method on it.

Is this new method fine to use everywhere? Any gotchas?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about syntax