JavaScript面向对象之自定义

<script type="text/javascript">
	var student=new Object();//创建学生对象
	//添加属性
	student.no=1000;//学号
	student.name='花花';//姓名
	student.age=20;//年龄
	student.gender='男';//性别

	//添加方法

	//考试
	student.test=function () {
		console.log('考试中......');	
	};

	student.study=function(){
		console.log('学习中。。。。。。。。。');
	};




	//访问对象
	console.log(student.no,student.name,student.age,student.gender);

	student.test();
	student.study();



	// node.aaaaa=100;//新增属性

	// var arr=[];
	// arr.name='花花';

	// console.log(arr.name);
</script>

猜你喜欢

转载自blog.csdn.net/weixin_44830974/article/details/89481448