Why does the MDN polyfill for Object.create have the following line:
Temp.prototype = null;
Is it so that we avoid maintaining a reference
Yes, exactly. This polyfill does hold the Temp
function forever in memory (so that its faster on average, not needing to create a function for every invocation of create
), and resetting the .prototype
on it is necessary so that it does not leak.
I think this is just clean, Temp.prototype is kind of static, since it is set before new Temp() it is nice to clean it after.