staafl

js - checking for constructor invocation

May 28th, 2013
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.16 KB | None | 0 0
  1. function SomeConstructor(a, b, c) {
  2. if(this === (function(){return this;}()))
  3. throw new Error("constructor invoked without 'new'!");
  4. // ...
  5. }
Advertisement
Add Comment
Please, Sign In to add comment