Add new methods to an object
We can add new methods to an object by setting the value of a property to be a function.
<!DOCTYPE HTML>
<html>
<head>
<title>Example</title>
</head>
<body>
<script type="text/javascript">
var myData = {
name : "JavaScript",
weather : "Good",
};
myData.sayHello = function() {
document.writeln(this.name);
};
myData.sayHello();
</script>
</body>
</html>