How to check if a function is a constructor
I noticed not all the Javascript functions are constructors. var obj = Function.prototype; console.log(typeof obj === 'function'); //true obj(); //OK new obj(); //TypeError: obj is not a constructor Question 1: How do I check if a function is a constructor so that it can be called with new keyword? Question 2: When I create a function, is it possible to make it NOT a constructor?
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.