5. “The World's Most Misunderstood
Programming Language”
by Douglas Crockford
6. The Ancestors of JavaScript
Functions
(Lamba)
Lexical Scope
Loosely
Typed
Prototypal
Inheritance
Dynamic
Objects
Syntax
Some
convention
Name (Part)
7. Did you mean ECMAScript?
1996 – First public release
1999 – Becomes standard ECMA-262 as
ECMAScript 3
2009 – Major update ECMAScript 5
2011 – Last review ECMAScript 5.1 (ISO/IEC
16262:2011)
WIP* – Next version ECMAScript 6
8. “JavaScript is the only language
people feel like they don't need to
learn to use it”
by Douglas Crockford
10. “Hidden under a hugesteaming
pile of goodintentions and
blunders is
anelegant, expressiveprogrammin
g language. A language of many
contrasts.”
by Douglas Crockford
13. Functions
Functions are first-class objects
Can be created at runtime
Can be stored in variables
Can be passed as parameters to functions
Can be returned by functions
Can be expressed as anonymous literals
25. Object Creation
JavaScript provides
several different ways to
create an object
Object Literal
When we need only
one object of some
kind
Reduce a large
number of parameters
Collect settings
26. Object Creation
JavaScript provides
several different ways to
create an object
Constructor Function
When we need many
independent instance
of some object
Add constructor
logic
Reduce memory
allocation
27. Object Creation
JavaScript provides
several different ways to
create an object
ECMAScript 5
Creating an object
without going through
its constructor
Better object‟s
properties specification
28. Information Hiding
JavaScript does not
offer accessibility levels
(public, private, etc.) on
members
This does not mean
that JavaScript objects
can‟t have private
members
30. Information Hiding
We can use functions
and closure to make
modules.
A module is a function
or object that
presents an interface
but that hides its
state and
implementation.
Also known as:
Module Pattern
31. Inheritance
(Pseudoclassical)Objects produced by
constructur functions
The prototype object
is the place where
inherited traits are to
be deposited
Create an object
whose prototype is
Function‟s prototype
and initialize it
executing Function
32. Pseudoclassical To The Max
Build a special class
object that
encapsulate repetitive
code
Use class object to
define other class
Instantiate new object
from class
35. Inheritance (Prototypal)
JavaScript natual way
Class-free
Objects inherit from
objects (Delegation)
Customizing the new
one (Differential
Inheritance)
Officially a part of the
language
(ECMAScript 5)
39. Inheritance (Functional)
Also known as Power
Constructors
Define maker function
composed by four
steps
Creates a new
object
Defines private
members
Augments that new
object
Returns that new
object
40. Callback
Functions can make it
easier to deal with
discontinuous events
Typically used to
make an
asynchronous
requests
Combining with
closure it become an
great way to hide the
complexity
41. Callback
Take care to use "this"
in the callback
Be careful when
callback is a method
of an object
44. Curry
Is a function
transformation
process (Haskell
Curry)
Produce a new
function by combining
a function and an
argument
When invoked, returns
the result of calling
that original
function, passing it all
of the arguments
54. Module Pattern
Modules are an
integral piece, it
provides a way of
wrapping methods
and variables
Protecting pieces from
leaking into the global
scope
Clean solution for
shielding logic
57. Asynchronous Module
Definition Pattern (AMD)
A format for writing
modular JavaScript in
the browser
Separate module
definition (define) and
dependencies loading
(require)
All can be
asynchronously
loaded