Question. What will expressions 1-4 return and why?
var A = function ( ) { } ; A. prototype . b = 100 ; var a = new A ( ) ; A. prototype . c = 101 ; a. c = - 100 ; A. prototype = { } ; A. prototype . b = 536 ; /* 1 */ console. log ( a.__proto__. constructor . prototype . b === 536 ) ; var b = new A ( ) ; /* 2 */ console. log ( a.__proto__.__proto__. constructor === a.__proto__. constructor . prototype . constructor ) ; /* 3 */ console. log ( b instanceof A ) ; /* 4 */ console. log ( ! ( a instanceof Object ) ) ;
var A = function ( ) { } ; A. prototype . b = 100 ; var a = new A ( ) ; A. prototype . c = 101 ; a. c = - 100 ; A. prototype = { } ; A. prototype . b = 536 ; /* 1 */ console. log ( a.__proto__. constructor . prototype . b === 536 ) ; var b = new A ( ) ; /* 2 */ console. log ( a.__proto__.__proto__. constructor === a.__proto__. constructor . prototype . constructor ) ; /* 3 */ console. log ( b instanceof A ) ; /* 4 */ console. log ( ! ( a instanceof Object ) ) ;
var A = function ( ) { } ; A. prototype . b = 100 ; var a = new A ( ) ; A. prototype . c = 101 ; a. c = - 100 ; A. prototype = { } ; A. prototype . b = 536 ; /* 1 */ console. log ( a.__proto__. constructor . prototype . b === 536 ) ; var b = new A ( ) ; /* 2 */ console. log ( a.__proto__.__proto__. constructor === a.__proto__. constructor . prototype . constructor ) ; /* 3 */ console. log ( b instanceof A ) ; /* 4 */ console. log ( ! ( a instanceof Object ) ) ;
var A = function ( ) { } ; A. prototype . b = 100 ; var a = new A ( ) ; A. prototype . c = 101 ; a. c = - 100 ; A. prototype = { } ; A. prototype . b = 536 ; /* 1 */ console. log ( a.__proto__. constructor . prototype . b === 536 ) ; var b = new A ( ) ; /* 2 */ console. log ( a.__proto__.__proto__. constructor === a.__proto__. constructor . prototype . constructor ) ; /* 3 */ console. log ( b instanceof A ) ; /* 4 */ console. log ( ! ( a instanceof Object ) ) ;
var A = function ( ) { } ; A. prototype . b = 100 ; var a = new A ( ) ; A. prototype . c = 101 ; a. c = - 100 ; A. prototype = { } ; A. prototype . b = 536 ; /* 1 */ console. log ( a.__proto__. constructor . prototype . b === 536 ) ; var b = new A ( ) ; /* 2 */ console. log ( a.__proto__.__proto__. constructor === a.__proto__. constructor . prototype . constructor ) ; /* 3 */ console. log ( b instanceof A ) ; /* 4 */ console. log ( ! ( a instanceof Object ) ) ;
var A = function ( ) { } ; A. prototype . b = 100 ; var a = new A ( ) ; A. prototype . c = 101 ; a. c = - 100 ; A. prototype = { } ; A. prototype . b = 536 ; /* 1 */ console. log ( a.__proto__. constructor . prototype . b === 536 ) ; var b = new A ( ) ; /* 2 */ console. log ( a.__proto__.__proto__. constructor === a.__proto__. constructor . prototype . constructor ) ; /* 3 */ console. log ( b instanceof A ) ; /* 4 */ console. log ( ! ( a instanceof Object ) ) ;
var A = function ( ) { } ; A. prototype . b = 100 ; var a = new A ( ) ; A. prototype . c = 101 ; a. c = - 100 ; A. prototype = { } ; A. prototype . b = 536 ; /* 1 */ console. log ( a.__proto__. constructor . prototype . b === 536 ) ; var b = new A ( ) ; /* 2 */ console. log ( a.__proto__.__proto__. constructor === a.__proto__. constructor . prototype . constructor ) ; /* 3 */ console. log ( b instanceof A ) ; /* 4 */ console. log ( ! ( a instanceof Object ) ) ;
var A = function ( ) { } ; A. prototype . b = 100 ; var a = new A ( ) ; A. prototype . c = 101 ; a. c = - 100 ; A. prototype = { } ; A. prototype . b = 536 ; /* 1 */ console. log ( a.__proto__. constructor . prototype . b === 536 ) ; var b = new A ( ) ; /* 2 */ console. log ( a.__proto__.__proto__. constructor === a.__proto__. constructor . prototype . constructor ) ; /* 3 */ console. log ( b instanceof A ) ; /* 4 */ console. log ( ! ( a instanceof Object ) ) ;
var A = function ( ) { } ; A. prototype . b = 100 ; var a = new A ( ) ; A. prototype . c = 101 ; a. c = - 100 ; A. prototype = { } ; A. prototype . b = 536 ; /* 1 */ console. log ( a.__proto__. constructor . prototype . b === 536 ) ; var b = new A ( ) ; /* 2 */ console. log ( a.__proto__.__proto__. constructor === a.__proto__. constructor . prototype . constructor ) ; /* 3 */ console. log ( b instanceof A ) ; /* 4 */ console. log ( ! ( a instanceof Object ) ) ;
var A = function ( ) { } ; A. prototype . b = 100 ; var a = new A ( ) ; A. prototype . c = 101 ; a. c = - 100 ; A. prototype = { } ; A. prototype . b = 536 ; /* 1 */ console. log ( a.__proto__. constructor . prototype . b === 536 ) ; var b = new A ( ) ; /* 2 */ console. log ( a.__proto__.__proto__. constructor === a.__proto__. constructor . prototype . constructor ) ; /* 3 */ console. log ( b instanceof A ) ; /* 4 */ console. log ( ! ( a instanceof Object ) ) ;
var A = function ( ) { } ; A. prototype . b = 100 ; var a = new A ( ) ; A. prototype . c = 101 ; a. c = - 100 ; A. prototype = { } ; A. prototype . b = 536 ; /* 1 */ console. log ( a.__proto__. constructor . prototype . b === 536 ) ; var b = new A ( ) ; /* 2 */ console. log ( a.__proto__.__proto__. constructor === a.__proto__. constructor . prototype . constructor ) ; /* 3 */ console. log ( b instanceof A ) ; /* 4 */ console. log ( ! ( a instanceof Object ) ) ;
var A = function ( ) { } ; A. prototype . b = 100 ; var a = new A ( ) ; A. prototype . c = 101 ; a. c = - 100 ; A. prototype = { } ; A. prototype . b = 536 ; /* 1 */ console. log ( a.__proto__. constructor . prototype . b === 536 ) ; var b = new A ( ) ; /* 2 */ console. log ( a.__proto__.__proto__. constructor === a.__proto__. constructor . prototype . constructor ) ; /* 3 */ console. log ( b instanceof A ) ; /* 4 */ console. log ( ! ( a instanceof Object ) ) ;
Source: https://habr.com/ru/post/108915/
All Articles