Please excuse me if I am missing anything important or even silly. I'm trying to print the constructor's name from objects. I followed two approaches.
First approach's code is below,
var CF = function () {
p1 = "";
p2 = "";
}
var cf1 = new CF();
cf1.constructor.name
Output :
""
second code,
function CF() {
p1 = "";
p2 = "";
}
var cf1 = new CF();
console.log(cf1.constructor.name);
Output :
CF
I guess you have undertood what I wanted to say. The first CF's objects constructor name is "" where as second ones output is CF.
I tried to know the differnce like below
var CF = function() { }
typeof CF;
function CF() { };
typeof CF
But no luck they both output
"function"
Why is that behavior with first approach? What is the difference?
(I'm using chrome console)