Timeline for Initiate all potential props of the object right away or as you go? [closed]
Current License: CC BY-SA 4.0
Post Revisions
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Dec 24, 2024 at 8:31 | vote | accept | Jurijs Kovzels | ||
| Dec 24, 2024 at 5:16 | history | closed |
Barmar esqew gnat |
Opinion-based | |
| Dec 24, 2024 at 0:50 | comment | added | Bravo |
of course, the cost obj = { etc is invalid syntax so that wouldn't work at all
|
|
| Dec 23, 2024 at 23:26 | answer | added | jmrk | timeline score: 5 | |
| Dec 23, 2024 at 23:26 | review | Close votes | |||
| Dec 24, 2024 at 5:19 | |||||
| Dec 23, 2024 at 23:11 | comment | added | Barmar | If you care about IDE development, initializing all the properties is probably best, since the IDE will then be able to provide property completion. Even better would be to use ES6 classes. | |
| Dec 23, 2024 at 23:09 | comment | added | Barmar |
If prop3 might not be needed, not creating it is almost certainly better performance-wise. It's hard to imagine how doing something can be faster than not doing it. The difference between using an object literal and assigning properties with assignments is probably negligible, but you should benchmark to be sure.
|
|
| Dec 23, 2024 at 22:58 | history | asked | Jurijs Kovzels | CC BY-SA 4.0 |