the world • It's the only language PPL think they don't have to learn it. ◦ When was the last time you learned JS? And not from other ppl code?! • JavaScript != Java ◦ Unlearning things is hard • Writing Java is easy. Writing JS is HARD!
return function f(v) { return a + v; }; }; var plus5 = plusX(5); var plus2 = plusX(2); plus5(10) -> 15 plus2(10) -> 12 • A function object contains: ◦ A function (name, parameters, body) ◦ A reference to the environment in which it was created (context) • This is a VERY good things ◦ Robust code (no global variables, no global functions) ◦ High performance
and holds its own data • Inheritance ◦ The ability for two classes to respond to the same (collection of) methods • Polymorphism ◦ The ability to define the behavior of one object in terms of another by sub-classing
object • When iterating over arrays don't call a.length at each iteration • Wrap everything in anonymous functions (function() { /* all code in your file goes here */ })(); •
which are not equal. var v = o[name];if (value == null) { // Wrong! should be === undefined alert(name + ' not found');} • for..in statement mixes functions as well as members • Allows block-less statements (like in C) if (foo) bar(); • Allows expression statements: foo; is a valid expression • There's only one Number type, Floating point, but it's IEEE flawed: 0.1 + 0.2 != 0.3 • phony array (bad for performance)
Javascript best practices ? (stackoverflow) • Object Oriented Programming in JavaScript • Comparison of JavaScript Inheritance Mechanisms; Proposal • On JavaScript Inheritance Performance and Libraries Troubles • On JavaScript Inheritance Performance - One Step Back