Use number based property names in JavaScript

Description

The following code shows how to use number based property names.

Example


<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var tutorial= {<!-- w ww  .j  a v a 2 s.co  m-->
"name" : "JavaScript",
"pageSize" : 9,
1: true
};
document.writeln(tutorial.name); //JavaScript
document.writeln(tutorial.pageSize); //9
document.writeln(tutorial["1"]); //
</script>
</head>
<body>
</body>
</html>

Click to view the demo

The code above generates the following result.

Use number based property names in JavaScript