<script type="text/ecmascript">
//demo0 写里面
var Class = function (arg) {
var private = arg + "私有。。。";
var privateF = function () {
return private;
};
Class.prototype.go = function () {
alert(privateF());
};
};
var wc = new Class("写里面:");
wc.go();
wc = Class = null;
</script>
<script type="text/ecmascript">
//demo1 写外面
Function.prototype.privateBind = function (object, prifuncs, names) {
try {
return eval(
[
"(function (" + names.join(", ") + ") {/nvar o = this;/n"
, "return function () {/n"
, "return "
, this.toString()
, ".call(o);/n}/n"
, "}/n)"
, ".apply(object, prifuncs)"
].join("")
);
} catch (exp) {}
};
var Class = function (arg) {
var private = arg + "私有。。。";
var privateF = function () {
return private;
};
this.go = this.go.privateBind(this, [privateF], ["privateF"]);
};
Class.prototype.go = function () {
alert(privateF());
};
var wc = new Class("写外面:");
wc.go();
wc = Class = null;
</script>
//demo0 写里面
var Class = function (arg) {
var private = arg + "私有。。。";
var privateF = function () {
return private;
};
Class.prototype.go = function () {
alert(privateF());
};
};
var wc = new Class("写里面:");
wc.go();
wc = Class = null;
</script>
<script type="text/ecmascript">
//demo1 写外面
Function.prototype.privateBind = function (object, prifuncs, names) {
try {
return eval(
[
"(function (" + names.join(", ") + ") {/nvar o = this;/n"
, "return function () {/n"
, "return "
, this.toString()
, ".call(o);/n}/n"
, "}/n)"
, ".apply(object, prifuncs)"
].join("")
);
} catch (exp) {}
};
var Class = function (arg) {
var private = arg + "私有。。。";
var privateF = function () {
return private;
};
this.go = this.go.privateBind(this, [privateF], ["privateF"]);
};
Class.prototype.go = function () {
alert(privateF());
};
var wc = new Class("写外面:");
wc.go();
wc = Class = null;
</script>