I've learned JavaScript and know how to write OO JavaScript, and I can accomplish those assignment like autocomplete, photo gallery with JavaScript, but I just don't know how to organize the codes. For example, when and where to define a function, how to organize those variables, etc.
So I'm looking for some good and simple examples of JavaScript project to learn the good practices. Can you suggest any? (such as a list data filter).
JavaScript in <head> or <body> You can place any number of scripts in an HTML document. Scripts can be placed in the <body> , or in the <head> section of an HTML page, or in both.
Keep Code Organized Our JavaScript code should be organized well so that they can be easily reasoned with. Well organized code don't repeat anything. Functions and classes inside all do one thing only and no more.
http://www.klauskomenda.com/code/javascript-programming-patterns/
That link discusses many different javascript organization patterns, including the one I prefer, the Revealing Module Pattern.
More information about the Revealing Module Pattern is here:
http://www.wait-till-i.com/2007/08/22/again-with-the-module-pattern-reveal-something-to-the-world/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With