Reference property name with space in JavaScript

Description

The following code shows how to reference property name with space.

Example


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

Click to view the demo

The code above generates the following result.

Reference property name with space in JavaScript