Javascript is a powerful and expressive programming language. Learning how to write Javascript properly by focusing on its good parts (and ignoring its bad parts) is a necessity if one wants to create maintainable code.
The work to do is:
- Show a simple alert while the webpage (created previously) is loading
- Use window.onload to execute code only when the whole content has been loaded
- Display the number of songs in an alert
- Show additional statistics like number of distinct countries and their names
- Hide all country names using Javascript and some CSS
- Use a timeout and callbacks to show/hide countries every second
The next step is to enhance the application to use jQuery (ready function, selectors, etc), one of the most formidable Javascript libraries ever.
jQuery can be used to easily:
- Display the table of songs with stripes (with the help of some CSS)
- Toggle the striped rows in the songs table when the mouse is over the table
- etc.
Finally, it is also important to know how to use a library like Underscore.js which provides a collection of useful functions (such as map, filter, uniq, etc.) to increase programmer productivity. Underscore.js simplifies existing (non-functional) Javascript code and, hence, make it more maintainable.
Leave a Reply