Skip to content

Instantly share code, notes, and snippets.

@NikitaGlukhi
Created December 10, 2018 12:53
Show Gist options
  • Save NikitaGlukhi/a804e847cc6c76e981832085476842b9 to your computer and use it in GitHub Desktop.
Save NikitaGlukhi/a804e847cc6c76e981832085476842b9 to your computer and use it in GitHub Desktop.
Tasks 1 for cunstructor functions
// Да, могут. Для этого они должны возвращать один и тот же объект
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
@korel-san
Copy link

let obj = {};
let obj1 = obj;
let obj2 = obj;

let C = function() {
return obj1;
};
let D = function () {
return obj2;
};

let c = new C();
let d = new D();

@korel-san
Copy link

https://gist.github.com/NikitaGlukhi/a804e847cc6c76e981832085476842b9#file-gistfile1-txt-L14
false??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment