<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JavaScript nested function</title>
</head>
<body>
<pre> <!-- Use pre element for work document.writeln() method -->
<script type="text/javascript">
function cal(){
var PI = 3.14;
function area(radius){
var area = PI * radius * radius;
document.writeln("Area of Circle: " + area);
}
cal.area = area;
}
var radius = 2.0;
cal();
cal.area(radius);
</script>
</pre>
</body>
</html>