这个问题是直截了当的。就像在 PHP 中我们有魔术函数一样__construct()
,我可以在 javascript 中使用任何相关的函数或 hack 吗?
例子:
function setLength() {
/* Some work */
}
var a = new Object();
b = new String("Hello");
//Is there anyway the function setLength() will automatically be fired when an Object or String... created?
我期待着你的回答。非常感谢您的帮助。
[X]