Create object with Object literal notation in JavaScript

Description

The following code shows how to create object with Object literal notation.

Example


<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var tutorial = {<!--from   w  w w.  ja  va  2s  . c o m-->
name : "JavaScript",
pageSize : 9
};

document.writeln(tutorial.name); //JavaScript
document.writeln(tutorial.pageSize); //9
</script>
</head>
<body>
</body>
</html>

Click to view the demo

The code above generates the following result.

Create object with Object literal notation in JavaScript