JS built-in mode

<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<Title> Комбинированный режим </title>
</head>
<body>
	<script type="text/javascript">
	// function food(){
	// 	this.showA = function(){
	// 		console.log('showA');
	// 	},
	// 	this.showB = function(){
	// 		console.log('showB');
	// 	}
	// }

	// function guke(){
	// 	this.diancan = function(){
	// 		var t = new food();
	// 		t.showB();
	// 		t.showA();
	// 	}
	// }

	// var g = new guke();
	// g.diancan();
	
 /*Можно использовать для хорошо вызовов кода и называть его более удобным*/
/*-----------------------------------------------------------*/
	function food(){}

	food.prototype.coffee = function(){
		console.log('coffee 000');
	}

	food.prototype.tea = function(){
		console.log('tea 111');
	}
    
    function guke(){}

    guke.prototype.diancan = function(){
    	var t = new food();
    	t.coffee();
    	t.tea()
    }

    var g = new guke();
    g.diancan()
	</script>
</body>
</html>

Leave a Comment