javascript language paradigms
DESCRIPTION
Talk given at The Rich Web Experience 2008. Check out my blog for the code samples.TRANSCRIPT
Object-oriented and
Functional JavaScript
jason harwig
why so long?
1.
“JavaScript is the world’s
most misunderstood language”
- douglas crockford
2.
no classes
public class Presentation {
public static void main(String[] a) { }
}
7
3.
“No JavaScript”
- pointy-haired boss
why now?
classical inheritance through
libraries
“I want it to be web 2.0”
- pointy-haired boss
what do I need to know?
1.
JSON
var presentation = {
};
19
name: ‘oojs’,
var presentations = [
];
20
var presentation = {
};
21
name: ‘oojs’
abstractasbooleanbreakbytecasecatchcharclasscontinueconstdebuggerdefaultdeletedodouble
elseenumexportextendsfalsefinalfinallyfloatforfunctiongotoifimplementsimportininstanceof
intinterfaceislongnamespacenativenewnullpackageprivateprotectedpublicreturnshortstaticsuper
switchsynchronizedthisthrowthrowstransienttruetrytypeofusevarvoidvolatilewhilewith
22
2.
“prototype is like a rosetta
stone”
- brian dillardjquery vs. prototype
3.
functions
functions as variables
functions without names
functions as constructors
functions vs methods
namespacing
objects
scopes
encapsulation
inheritance
no dot equals?!?
libraries
prototype.js
Presentation = Class.create({
initialize: function() { }
})
40
JQuery Classy Query
JavaScript 2.0