tôi đang tìm kiếm một nhà xây dựng hoặc một hàm init cho sau tình huống:Constructor hoặc init chức năng cho một đối tượng
var Abc = function(aProperty,bProperty){
this.aProperty = aProperty;
this.bProperty = bProperty;
};
Abc.prototype.init = function(){
// Perform some operation
};
//Creating a new Abc object using Constructor.
var currentAbc = new Abc(obj,obj);
//currently I write this statement:
currentAbc.init();
Có cách nào để gọi hàm init khi đối tượng mới được khởi tạo?
Đặt nó vào trong contructor. –