This is my playground to learn and try of Javascript new feature, you free to clone or fork for learning purpose.
- Do not use global variable to prevent collision variable with library or your code, instead use namespace to declare variable com_sketchproject = {}; com_sketchproject.name = 'angga';
- Always use semicolon for statement.
- Prefer camelcase naming convention.
- Declare variable of function before it's called.
- Avoid a language construct such as: eval(), new Function('string_function_code').
- Use built-in function whenever possible, they implement in native code in the browser.
- REMEMBER: (Pass by value) Primitive values like numbers are passed to functions as a distinct copy of themselves. Changing them has no effect. ({ass by reference) Object and arrays, however are passed by reference. if you change their contents inside a function, that change does have and effect.
- Don't pass string function code to setInterval() and setTimeout() instead use anonymous or declared function.
- Use += operator concat string instead + string + string + string.
- Use innerHTML instead of using the dom node such as appendChild, insertBefore, nodeValue.
- Avoid making large-scale DOM change one at a time. Instead, make changes to a temporary object, modify that then copy the result back into the document (to avoid big reparse/reflow document).
- It's good practice to separate js from presentation (html)
- No inline event attributes such href="javascript:function()"