JavaScript中对象的使用

<html>
	<head>
		<title>
			wodeweb
		</title>
	</head>
	<body>
		<script type="text/javascript">
			//Object.prototype.color=null;  可去可不去
			Object.prototype.shift=function()
			{
				//this.color=null;必须去掉否则错误
				alert(this.color+(this===Object));//this不是Object
			}
			var redCar=new Object();
			redCar.color="红色";
			var blueCar=new Object();
			blueCar.color="蓝色";
			redCar.shift();
			blueCar.shift();
			/*function Car()
			{
				this.color=null; //可去可不去   
				this.shift=function()
				{
					alert(this.color+"汽车");
				}
			}
			var redCar=new Car();
			redCar.color="红色";
			redCar.shift();*/
		</script>
	</body>
</html>

原文地址:https://www.cnblogs.com/zztong/p/6695255.html