JavaScript 对象
JS Array
JS Boolean
JS Date
JS Math
JS Number
JS String
JS RegExp
JS Functions
JS Events
[url]http://www.w3school.com.cn/js/js_reference.asp[/url]
prototype 属性使您有能力向对象添加属性和方法。
语法
JS Array
JS Boolean
JS Date
JS Math
JS Number
JS String
JS RegExp
JS Functions
JS Events
[url]http://www.w3school.com.cn/js/js_reference.asp[/url]
prototype 属性使您有能力向对象添加属性和方法。
语法
object.prototype.name=value
<script type="text/javascript">
String.prototype.trim = function() {
return this.replace(/^[\s\u3000\xA0]+|[\s\u3000\xA0]+$/g,"");
}
function Employee(name,job,born)
{
this.name=name;
this.job=job;
this.born=born;
this.getName=emp_getName;
}
function emp_getName(){
return this.name;
}
var bill=new Employee(" Bill Gates","Engineer",1985);
Employee.prototype.salary=null;
bill.salary=20000;
document.write(bill.salary);
document.write(bill.name.trim());
-- 结果2000Bill Gates
</script>