1

I have a JavaScript object like:

appointerment= {ids: '15,16,17', appointments: {'15': '12.05.2010,14,05,2010'} }

now in appointments object I want to add something like '16': '21.05.2010'

what is the best possible way to do this?

3 Answers 3

6
appointerment.appointments['16'] = '21.05.2010';

JSON is short for "JavaScript Object Notation", and as the name implies, it's basically just a way of representing Javascript objects. Thus, one can interact with JSON in the ways one tends to interact with any other object in Javascript, via the usage of the . or [] operators.

Sign up to request clarification or add additional context in comments.

Comments

0
appoiterment['appointments']['16'] = '21.05.2010';

1 Comment

This is wrong. I assume you meant appoiterment['appointments']['16']?
0
var x = { a:1, b:{c:1} }

x.b.d = 1

// x is now { a:1, b:{c:1, d:1} }

Note - But this won't work in the case of numbers like '16'.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.