I'm getting a bit confused with the new keyword in JavaScript. Take the following example
function A (value) {
this.a = value;
}
function B (value) {
return new A (value);
}
console.log ( B (0)); // { a: 0 }
console.log (new B (0)); // { a: 0 }
I want to be able to create a new instance of "A" without having to use "new". For that I have "B()", however, when I call "new B()" it appears to do the same thing as "B()", as though "new" was ignored. In both cases, instanceof equals "A". What exactly is going on?