87,993
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Example</title>
<script>
function Parenizor(value) {
this.setValue(value);
}
Parenizor.method('setValue', function (value) {
this.value = value;
return this;
});
Parenizor.method('getValue', function () {
return this.value;
});
Parenizor.method('toString', function () {
return '(' + this.getValue() + ')';
});
</script>
</head>
<body>
</body>
function Parenizor(value) {
this.setValue(value);
}
Parenizor.prototype.setValue = function (value) {
this.value = value;
return this;
};
Parenizor.prototype.getValue= function () {
return this.value;
};
Parenizor.prototype.toString=function () {
return '(' + this.getValue() + ')';
};
var p = new Parenizor(123);
alert(p.toString())