Created
December 10, 2018 12:53
-
-
Save NikitaGlukhi/a804e847cc6c76e981832085476842b9 to your computer and use it in GitHub Desktop.
Tasks 1 for cunstructor functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Да, могут. Для этого они должны возвращать один и тот же объект | |
const obj = {}; | |
const A = function() { | |
return obj; | |
}; | |
const B = function () { | |
return obj; | |
}; | |
const a = new A(); | |
const b = new B(); | |
alert(a == b); // false | |
// Вот так выведет false. Почему так? Потому что сравниваются ССЫЛКИ НА ОБЪЕКТЫ, а не сами объекты(какими бы одинаковыми они не были) | |
// const obj1 = { name: 1 }; | |
// const obj2 = { name: 1 }; | |
// | |
// const A1 = function() { | |
// return obj1; | |
// }; | |
// const B1 = function () { | |
// return obj2; | |
// }; | |
// | |
// const a1 = new A1(); | |
// const b1 = new B1(); | |
// | |
// alert(a1 == b1); // false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/NikitaGlukhi/a804e847cc6c76e981832085476842b9#file-gistfile1-txt-L14
false??