| Refresh | Home EGTry.com


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>Untitled</title>
</head>

<body>
<script>
function show(obj) {
	
		document.writeln("name="+obj.name+"<br>");
		document.writeln("value="+obj.value+"<br>");
		
	document.writeln("<p></p>");
}

function product(name, value){
	this.name = name;
	if(value > 1000)
		this.value = 999;
	else
		this.value = value;
}

function prod_dept(name, value, dept){
	this.dept = dept;
	product.call(this, name, value);  // this method is not support
}
prod_dept.prototype = new product();

// since 5 is less than 100 value is set
cheese = new prod_dept("feta", 5, "food");
show(cheese);

// since 5000 is above 1000, value will be 999
car = new prod_dept("honda", 5000, "auto");
show(car);
</script>

</body>
</html>