亚洲色蝴蝶中文娱乐网,在线亚洲欧美一区二区中文字幕,无人视频在线观看视频高清视频,99午夜国产精品一区二区,人人妻人人爽人人狠狠

ES5中prototype的應(yīng)用

時(shí)間:2019-09-12 14:47:56 類型:JS/JQUERY
字號(hào):    

ES5中prototype的應(yīng)用, 在JS中,函數(shù)同時(shí)也是一個(gè)對(duì)象, 向這個(gè)函數(shù)對(duì)象中添加屬性及函數(shù)可使用prototype這個(gè)屬性


<script type="text/javascript">
		function Obj(){
			this.name ="南昌雅騰";
			this.success = function(){
						console.log('成功');
					}
		}
		Obj.prototype.address = "南昌艾溪湖邊上";
		Obj.prototype.getName = function(){
			return this.name;
		}

		var app = new Obj();
		console.log(app.getName());
	</script>