javascript对象的继承顺序、分类和内置Math对象
时间:2014-09-26 点击:次
对象的继承顺序、分类和内置Math对象
一、对象的继承顺序
Object.prototype.say=function () {
alert("我是顶层的方法");
}
function person () {
this.say=function () {
alert("我是父类的方法");
}
}
person.prototype.say=function () {
alert("我是父类原型的方法");
}
function study () {
this.say=function () {
alert("本身的方法");
}
}
study.prototype=new person();
study.prototype.say=function () {
alert("本身原型的方法");
}
var zhangsan=new study ();
alert(zhangsan.say)
二、对象的分类
1.内置对象
Global
Math
2.本地对象
Array
Number
String
Boolean
Function
RegExp
3.宿主对象
DOM
BOM
三、Math对象
格式: Math.方法(参数)
1.取绝对值
Math.abs();
2.取近似整数
//Math.round() 四舍五入
//Math.floor() 对数进行下取舍
//Math.ceil() 对数进行上取舍
3.取最大值或最小值
Math.max(参数....)
Math.min(参数.....)
4.取随机数
Math.random();