I've a question about JavaScript object property name. Check out codes below:
<!DOCTYPE html>
<meta charset="UTF-8">
<title>An HTML5 document</title>
<script>
var obj = {
123: 'go' // 123 is not a valid JavaScript name. No error here.
};
var obj2 = {
123a: 'go' // An Error occurred.
};
</script>
If a JavaScript object's property name is a valid JavaScript identifier, object porperty name's quotes are not necessary.
E.g.
({go_go: 'go'}); // OK
({go-go: 'go'}); // Fail
In the codes above, 123a is an invalid JavaScript name and it's not be quoted. So An error occurred. But 123 is also an invalid JavaScript name and also it's not quoted, why no error here? Personally I think 123 must be quoted.
Thank you!