A Question on Prototype Writing

  javascript

I now have an object o, I need to add an init method to the object o, written as follows:
The first is:

O.prototype = {
 init:function () {
 bracket
 bracket

The second is:

O.prototype.init = function () {
 bracket

Is there any difference between these two writing methods? And is there anything to note on the call?

In fact, all can play a role in extending the method on the prototype of O, but if you have many methods, we still use the first method more for the sake of maintainability, robustness and readability of the code, at least the method that is commonly used by the general public, hoping to be helpful to you.