Access a not-defined properties for an object in JavaScript

Description

The following code shows how to access a not-defined properties for an object.

Example


<!DOCTYPE HTML>
<html>
<body>
<script type="text/javascript">
var myData = {<!--from w w  w .j  a  v  a2  s  .com-->
name : "JavaScript",
weather : "good",
};
document.writeln("Prop: " + myData.doesntexist);
</script>
</body>
</html>

Click to view the demo

The code above generates the following result.

Access a not-defined properties for an object in JavaScript