日期:2014-05-16 浏览次数:20422 次
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; } 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>