I feel that the second one is more troublesome than the first one. Are there any advantages?
我想大声告诉你2017-07-05 11:00:44
When the CheckObject
object has many attributes, the entire function body is too long, which affects the reading of the code. In the second method, each attribute of the object is a method, which is short and concise, highly readable, and the code logic is the same. Of
代言2017-07-05 11:00:44
I don’t feel that the second one has any obvious advantages. I like the first one, or else the second one should be changed like this
var CheckObject = function(){};
CheckObject.prototype.checkName = function() {
}
var check = new CheckObject();
check.checkName();