✅ – shuntera12 – 23-03 Nov 9
Hey everyone! How to add a property to object after a particular property?
Like if
const obj = {
a:"Name",
b:"Rohit",
age:12,
}
and i want to add the property after b, can anyone help me with this?14 Replies
so in my case there are thousand objects with different structure but same property names, and I want to add a new property after a particular property, how will I do so?
You should not use an object if you want a specific order
You should use an array instead
What's the use case here? @shuntera12
I am using Prismic (CMS) and I want to change the data of the CMS, since there is no write API, I would need to manually upload JSON files to the CMS.
Now, the CMS will only work if the imported json file is in correct order/structure. Therfore, i want to add new properties in json file at the correct order
@S3BAS
Now, the CMS will only work if the imported json file is in correct orderAre you really, really sure about this? I highly doubt that's a requirement
Lemme checkkk
There's nothing mentioned in the docs about the structure, but my senior told me that the structure should remain the same
@S3BAS what should I do now? 😓
The structure in terms of keys/values being present sure
But the order should not matter
so can I proceed with adding properties at random order, right?
Have you tried it out? :p
(but yes, very likely)
I don't have access to upload, only thing I can provide my manager is my json file
Ah, but yeah the order of the keys in the object should not matter
yep, thanks for clarifying
💯

This question has an answer! Thank you for helping 😄
If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1040038858521317416
This thread hasn’t had any activity in 12 hours, so it’s now locked.
Threads are closed automatically after 12 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1040038858521317416
Question not getting answered? Maybe it's hard to answer, or maybe you asked at a slow time. Check out these resources for help asking a good question:
https://stackoverflow.com/help/how-to-ask
http://wp.me/p2oIwo-26