function object(o) { o = Object(o); function F() {} F.prototype = o; var obj = new F(); var methods = ["toString", "toLocaleString", "valueOf"]; for (var i = 0; i < methods.length; i++) with ({ method: methods[i] }) obj[method] = function () { return o[method].apply(o, arguments); }; return obj; } var myStr = object("子"); myStr.x = function (n) { var s = ""; while (n--) s += this; return s; }; alert(myStr.x(12));