JavaScript Objects
Similar to other programming languages javascript objects is a collection of key-value pairs, where each key is a str...
For further actions, you may consider blocking this person and/or reporting abuse
You've missed
Object.fromEntries
as a creation method.Keys can also be
Symbol
sTrue if the key is a string, but if the key is a
Symbol
, bracket notation must be used.Also important to note is that you can create an object with no prototype (a
null
prototype) by passingnull
as the first (prototype) parameter. This is useful for saving memory, creating enums, or dealing with objects that potentially use names that clash with default object methods.Beautiful. It's important to say for novels in models javascript.
thank you @jonrandy for the feedback. Really appreciate; and will surely change and add the statements.
I appreciate your great effort, well done.
However the post is full of errors, please review your code snippets and republish it - we need to be responsible about the quality of information we provide to the audience.
Cheers my friend
hey bek
thank you for the awesome feedback
yes, I'm also improving the article daily so this can become one stop for the js object reference in dev to.
Awesome, my friend !
I think there's a mistake in code of Object.freeze
Thank you Yogesh,
Updated
That's weird...
If you mean the cover image, I agree.
haha, I am experimentingπ
Keep it up! There's nothing wrong with it. It's just... unusual. π
hey,
can you elobrate so I can fix and improve.
A very good and informative article.
Thank you suraj
You are very unprecise about the use of "new" in 2. Using the new Keyword! See this example:
"new" creates an object containing an internal "this". If you omit "new", this is the global context, so your properties are created outside of your object.
Using or not using "new" will lead to very hard to track errors. If you use "new" only 1,8% of the time, 98,2% your code will not work as expected.
Thank you eckehard for you feedback.
Will update the post,
those percentages i have put are for the methods you will use for creating objectsπ
Using
new
to create an instance of an object is very common. It's pretty much the basis of how OOP works in JS.I guess accidentally forgetting "new" is pretty common too. ThatΒ΄s what I hate about OOP in Javascript.
You had my like just from the cover image π. Great article as well
haha tried something newπ
A great consolidation of javascript object
thank you kiran
Why you didn't review the
valueOf
?That allows you to create "smart" & "magic" numbers or something else
Example: