Posted under Javascript
Permalink
Tags Javascript, Tip, Tutorial
There are a number of pros and cons regarding this practice, and they are debated on StackOverflow here. A w3schools tutorial on it may be found here.
I have used this e.g. here, following the lead of the Primefaces dialog.js. A downside is that your code fails if you forget the new and just call the function instead. However, this can be detected and an error thrown as per the StackOverflow post. In my case, the thrown error was not easily detected so I elected to pop an alert as well.
I do not discuss the issue further here – just follow the links and you will find plenty of information on it.
Leave a Reply
You must be logged in to post a comment.