I am very new to javascript. We can write json as follows
const obj1 = {key: "myKey", value: "myValue"}
const obj2 = {"myKey": "myValue"}
what is a difference between these two? And when should I prefer using one over another?
I am very new to javascript. We can write json as follows
const obj1 = {key: "myKey", value: "myValue"}
const obj2 = {"myKey": "myValue"}
what is a difference between these two? And when should I prefer using one over another?
The first one is the JavaScript way. The second one would be JSON format. You can use both in JavaScript. My preference is the first way.
There isn't a difference. Write however you want. I personally prefer the key not to be a string.var a = {key: "value"}