Paytm interview question

How to make a function that will check if it is called with new keyword or a normal function?

Interview Answer

Anonymous

22 May 2018

function x(y) { if (this.constructor == x) alert['called with new'); else alert['called as function'); }