javascript - What are the advantages of these two ways of writing functions?
三叔
三叔 2017-07-05 10:58:44
0
2
833

I feel that the second one is more troublesome than the first one. Are there any advantages?

三叔
三叔

reply all(2)
我想大声告诉你

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

代言

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();
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template