Create an object and add new properties in JavaScript

Description

The following code shows how to create an object and add new properties.

Example


<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var tutorial = new Object();<!--   ww w .java2 s  . c o  m-->
tutorial.name = "JavaScript";
tutorial.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 an object and add new properties in JavaScript