I know there are some questions that may refer to this, but I didn't find anything related to javascript strictly.
For example this: JSON Spec - does the key have to be surrounded with quotes?
But my question is: should we use quotes when we write a Javascript Object?
I think it is more elegant to write is without quotes and also more readable, but is it OK?
For example when I use it to pass as an argument:
myFunction({
"key": "value",
"otherKey": 10
});
myFunction({
key: "value",
otherKey: 10
});
Also as I read, the second one works in every browser, unless it is a forbidden word (for, if, etc), so this wouldn't be a problem.
I think the second one looks better, but I also think it may not be a good practice..
I did this practice for years and now I am starting to think that I was wrong but I don't feel it good using quotes.. What should I do?