Похожие чаты

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 ответов

26 просмотров

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.

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

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

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта