Answer the question
In order to leave comments, you need to log in
Javascript constructor paradox?
I am learning Javascript, in order to create an object, I need to write
And as it was described on different sources learn.javascript, habrhabr, toster, stackoverflow
that using this construction is a bad form, and it is better to use such a construction
I can’t understand why it’s bad?
If in any case I need to call the constructor of something somewhere in the code, in this case it is
I need a function that returns the current time, but I need to call the constructor, and I remembered why it’s impossible / call badly
Can you describe what the problem is
Resources, time, something else?
--UPDATE
No, I don't want to call new Object() everywhere, they just write what is bad/wrong, but I didn't see an explanation why..var obj = new Object();
var obj = {};
var date = new Date();
new Object()?
new Object()?
Here is an article, translation of the Airbnb JavaScript Style Guide
https://github.com/uprock/javascript#objects
In objects, it is described that var variable = new Object() is bad, and var variable = {} is good, but it is not written why.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question