Question #34

Author: admin
tags: JavaScript  
'use strict';

function MakeObj() {
  const x = 1;
}

MakeObj.prototype = { x: 4 };

const obj1 = new MakeObj();
const obj2 = new MakeObj();

obj2.__proto__ = obj1;

MakeObj.prototype = null;

console.log(obj2.x);
What will the console output be?
1
4
Nothing. Due to the strict mode, an error will occur.
undefined
null
The string MakeObj.prototype = null; did not affect obj1 and obj2 objects, because the references inside the __proto__ ([[Prototype]]) properties remained the same.
obj1.__proto__ has reference to the { x: 4 }, and obj2.__proto__ has reference to the obj1.
Rate the difficulty of the question:
easyhard