Posted almost 3 years ago. Visible to the public.

JavaScript basics

Play with the language:

  • Variables
  • Loops
  • Functions
  • Understand the difference between function pointers ("anonymous functions") and function invocations
    • Understand the parallels between blocks/lambdas in Ruby and anonymous functions in Javascript

Resources

Goals:

You should be able to answer the following questions:

  • Understand why we need JavaScript
  • Understand what jQuery does
  • Understand how to select DOM elements using jQuery
  • Understand the difference between a jQuery collection/object/result set and naked DOM elements
    • Open any web page and use jQuery to select DOM nodes from a browser's developer console
  • Understand how to register event handlers using jQuery
  • Understand why we often use a library "Lodash.js" or "Underscore.js"
  • There are no classes in JavaScript. Understand some workarounds that people use:
  • Understand what this is in Javascript and why it's painful to use it
  • Understand why we sometimes use Coffeescript (you don't need to understand the language in its entirety)

  • Exercises

  • Write your own version of the Array.map function. Name it myMap. It should work exactly like Array.map, but should be your own code.
  • Can you write a Javascript function mySelect that works like Ruby's Enumerable#select, only as a Javascript equivalent?
  • In your MovieDB, in the movies list, add a button that says "Count movies". Once the user clicks on that button, a piece of Javascript will count the movies in the list above and replace the button text with the number of movies counted.

Author of this card:

Avatar
Henning Koch
Last edit:
about 1 month ago
by Henning Koch
Posted by Henning Koch to makandra Curriculum