JavaScript的内置对象和函数

来源:互联网 发布:淘宝服装店描述句子 编辑:程序博客网 时间:2024/05/18 21:50

javascript 内置对象:1.Date 2.Math 3.Number 4.Boolean 5.String 6.Array 7.RegExp

8.Function
属性:
arguments    An array corresponding to the arguments passed to a function.
arity      Indicates the number of arguments expected by the function.
caller      Specifies which function called the current function.
prototype    Allows the addition of properties to a Function object.

方法:
toString     Returns a string representing the specified object.

 

9.Object
属性:
constructor Specifies the function that creates an object's prototype.
prototype    Allows the addition of properties to all objects.

方法:
eval       Evaluates a string of JavaScript code in the context of the specified object.
toString     Returns a string representing the specified object.
unwatch     Removes a watchpoint from a 属性源 the object.
valueOf     Returns the primitive value of the specified object.
watch      Adds a watchpoint to a 属性源 the object.

10.全局
属性:
Infinity     指定一个正负无穷大的数值
NaN       指定一个 “非数字” 值
undefined    指定一个未被赋值的变量

11.事件
属性:
a.窗口事件,只在body和frameset元素中才有效
onload      页面或图片加载完成时
onunload     用户离开页面时

b.表单元素事件,在表单元素中才有效
onchange     框内容改变时
onsubmit     点击提交按钮时
onreset     重新点击鼠标按键时
onselect     文本被选择时
onblur      元素失去焦点时
onfocus     当元素获取焦点时

c.键盘事件,在base,bdo,br,frame,frameset,head,html,iframe,meta,param,script,style,title元素里都无效
onkeydown    按下键盘按键时
onkeypress    按下或按住键盘按键时
onkeyup     放开键盘按键时

d.在base,bdo,br,frame,frameset,head,html,iframe,meta,param,script,style,title元素里都无效
onclick     鼠标点击一个对象时
ondblclick    鼠标双击一个对象时
onmousedown 鼠标被按下时
onmousemove 鼠标被移动时
onmouseout    鼠标离开元素时
onmouseover 鼠标经过元素时
onmouseup    释放鼠标按键时

e.其他
onresize     当窗口或框架被重新定义尺寸时
onabort     图片下载被打断时
onerror     当加载文档或图片时发生错误时

自定义对象:有初始化对象和定义构造函数的对象两种方法
a:初始化对象
例如: 对象={属性1:值1;属性2:值2;......属性n:值n} 注意:每个属性/值对之间用分号隔开;

b: 定义构造函数的对象
例如:
function 函数名(属性1, 属性2,......属性N){
this.属性1=属性值1;
this.属性2=属性值2;
this.属性n=属性值n;

this.方法名1=函数名1;
this.方法名2=函数名2;
}

注意:方法名和函数名可以同名,但是在方法调用函数前,函数必须已经定义好,否则会出错

为自定义的函数创建新的实例一样是使用 new 语句。

 

原创粉丝点击