Says I have var input = {'name':'john'}
I do
input['name'] = 'James'
it become var input = {'name':'john'}
but can I pass value with dot to access nested property?
Like
var input = {"name":"john","grades":"{english:"A","math":"C"}"}
I can't change the math value by doing input["grades.math"]
.
You can access that value by these ways:
var input = {"name":"john","grades":{"english":"A","math":"C"}}
console.log(input["grades"]["math"]);
console.log(input.grades.math);
console.log(input["grades"].math);
console.log(input.grades["math"]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With