Javascript---- 练习九(对象)

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script type="text/javascript">
/********************
1.请为网吧做一套系统,用于凭借身份证号码检测一个人是否成年,成年则欢迎,不成年则请出。
提示:new Date();获取时间
string.sub();截取字符串
********************/

/*var birth = '1992,09,20';
var births = birth.split(",");

var s = ((parseInt(births[0]))+18)+","+births[1]+","+births[2];
var birthDay = new Date(s);
console.log(birthDay);
var nowDay = new Date();

if(nowDay.getTime()>=birthDay.getTime()){
alert("恭喜你!你已成年!");
}
else{
alert("骚年,你还没成年");
}
*/



/********************
2.用至少两种定义对象的方式来定义一辆车,车有对应的属性(例如有尺寸,颜色,马力)和方法(行驶,开车灯)
(请至少写出4个属性,2种方法)
********************/
/*
var car = function(size,color,power){
this.size = size;
this.color = color;
this.power = power;
this.run = function(){
console.log("running");
}
this.light = function(){
console.log("lighting");
}
}

var car1 = new car();
car1.run();*/
</script>
</body>
</html>

原文地址:https://www.cnblogs.com/SunlikeLWL/p/7240422.html