Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← 03-53 Anonymous Functions in JavaScript

dummy description

Get Embed Code
3 Languages

Showing Revision 1 created 05/04/2012 by Amara Bot.

  1. Now that we've seen this one way, let's see this from a different perspective.
  2. [Brendan Eich, CTO, Mozilla] [Wes Weimer, Professor, University of Virginia]
  3. Let me ask you a question that's actually of personal interest and curiosity to me.
  4. I'm teaching in this class a number of elements of functional programming,
  5. list comprehensions in Python, filtering a list to retain only some required elements,
  6. and I noticed that in JavaScript you included the ability to create
  7. an anonymous function with the function keyword.
  8. And for students initially, that might be a little bit confusing because
  9. declaring a function at the top level also uses the function keyword,
  10. but we can get past that with the grammar.
  11. I'm curious, why did you think it was important to include the ability
  12. to have anonymous functions?
  13. JavaScript had to live in the shadow of Java,
  14. but it was its own language, and the original pitch--
  15. the sort of fraudulent pretense for getting me to Netscape--was to do Scheme.
  16. Now, I didn't have time to do Scheme, and I didn't do anything as pretty as Scheme,
  17. but JavaScript is a language with first class functions,
  18. and functions are the main building block, so it's important not simply to have
  19. function declarations and require you to name them and put them at a certain level
  20. in nesting but to allow you to express them freely as anonymous functions
  21. or even named function expressions, and this is incredibly popular today.
  22. This is used in lieu of modules and to make sort of super constructors
  23. and class systems in JavaScript today
  24. using functions and function expressions.