Demenstrate that Primitive values can't have dynamic properties in JavaScript

Description

The following code shows how to demenstrate that Primitive values can't have dynamic properties.

Example


<!--from ww  w.  j a v  a2s . co  m-->
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var name = "JavaScript";
name.age = 20;
document.writeln(name.age); //undefined

</script>
</head>
<body>
</body>
</html>

Click to view the demo

The code above generates the following result.

Demenstrate that Primitive values can