I have the following object:
If I try to get the value from it by using let result = object.3h
I get the following error
error: `Parsing error: Identifier directly after number`.
I have the following object:
If I try to get the value from it by using let result = object.3h
I get the following error
error: `Parsing error: Identifier directly after number`.
you need to use bracket notation
correct
object["3h"]
incorrect
object.3h
const object = { "3h": 0.44 }
console.log(object["3h"])
Identifiers in Javascript can’t start with a number (You can check the exact rules at the link provided.
When dealing with object properties, you can use string literals for defining properties that won’t follow this rule (Which might also happen when dealing with JSON objects)
In order to access this properties you need to use a property accessor
On your case:
day.rain[‘3h’]