JavaScript for WordPress Forums Vanilla JavaScript function style Reply To: function style

Zac Gordon

Hi Merrill,

This is a really good question.

What you are seeing here is a style of writing an init method that is not necessarily a best practice but is not uncommon.

The reason for this is mostly for readability and to keep the object declaration close to the initializing method for that object. There are not really technical difference between how init and the other methods are written and init could have been written in the same way as them and vice versa.

When I was building this project I did try to write things in a few different ways to expose us to things like this and you did a good job to bring it up here.

I could say more, but let me know if this answers your question for you 🙂

Sorry for the delay in response as well. Notifications plugin reactivated!