Похожие чаты

The idea of the singleton pattern is to have only

one instance of a specific class. This
means that the second time you use the same class to create a new object, you should
get the same object that was created the first time.
And how does this apply to JavaScript? In JavaScript there are no classes, just objects.
When you create a new object, there’s actually no other object like it, and the new
object is already a singleton. Creating a simple object using the object literal is also an
example of a singleton:
var obj = {
myprop: 'my value'
};
In JavaScript, objects are never equal unless they are the same object, so even if you
create an identical object with the exact same members, it won’t be the same as the first
one:
var obj2 = {
myprop: 'my value'
};
obj === obj2; // false
obj == obj2; // false
So you can say that every time you create an object using the object literal, you’re
actually creating a singleton, and there’s no special syntax involved.

11 ответов

23 просмотра

OOP brainwashed

It's also very dated

this looks very outdated, i think the book is written pre ES6

Emre- Автор вопроса

I would suggest not going for so many books, but YDKJS is probably a better book

Emre- Автор вопроса
Emre
it also is not recent though, right

YDKJS is frequently updated and online

Emre- Автор вопроса
Thomas
YDKJS is frequently updated and online

i saw that 3rd edition is not avaliable yet, so that was my assumption. thank you

Emre
i saw that 3rd edition is not avaliable yet, so th...

2nd edition was last updated 40 minutes ago

Emre- Автор вопроса
Thomas
2nd edition was last updated 40 minutes ago

thank you very much, I was not aware.

Похожие вопросы

Обсуждают сегодня

30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
Also, why can’t the community have a vote/ say when it comes to initiatives like buybacks. Isn’t the point of crypto decentralisation? Don’t we deserve input as long term supp...
👨🏽‍🦰
13
Чёт не понял, я ж правильной функцией воспользовался чтобы вывести отладочную информацию? но что-то она не ловится
notme
18
Привет)) уже кажется эту тему перемусолили, но вот я так и не понял. Я сейчас сижу на 27дюймов 2к мониторе. На Актуальной макоси, если я куплю 27д 4к монитор: - будет ли изобр...
Vladislav Piskunov
15
any reference of this implementation?
BitBuddha
29
Hi guys, any problem with Pulsebrige? Trying to transfer from wETH to ETH. First it tells me to connect my metamask "through mobile app" not desktop. Then I did and confirmed ...
Snowflakecrypto
13
У меня есть функция где происходит это: write_bit(buffer, 1); write_bit(buffer, 0); write_bit(buffer, 1); write_bit(buffer, 1); write_bit(buffer, 1); w...
~
13
Страшнейшая правда про списки ЦБ. С первых дней жизни P2P сферы, молодые человеки, начитавшись законодательной базы и "внутренних" документов, решили, что им противостоит сер...
Foxcool
3
Карта сайта