I am trying to find in the docs / understand this behavior for the following code:
I saw this piece of code here :
function f(){ return f; } new f() instanceof f;
This is because (from what I read ):
When the constructor object returns an object, the new operator will give the returned object
Since f is a function , the new operator returns a return object, which in this case is f
So: new f() === f
Therefore: f instanceof f // false.
Question:
I searched for this description of behavior in documents, but could not find it.
I found only a partial answer in mdn :

However - looking at the docs (this is what I really am after):
All he says is:

It does not mention cases where constructor return object or not (I'm sure it is missing)
Question: Where do the documents explain this behavior?
nb
I know that the constructor function should not (in general) return anything, this question is for knowledge.
nb2:
an example for this behavior:
var z = {a: 2}; function g() { return z; } var x = new g(); x === z;
Here x is actually equal to z, right up to the identity!
javascript
Royi namir
source share