Why should I know javascript?
It's being used in all areas of Development
Web Development
Mobile Development
Gaming
Multi-platform middle layer
Productivity Software
Web Development
Web Frameworks
AngularJS, KnockoutJS, Backbone, Ember
Libraries
Breeze, underscore, jQuery, mooTools, Prototype, YUI
DOM Plugins
(too many to fit on this screen)
MOBILE
Corona SDK
MULTI-PLATFORM NATIVE
PCs, Tablets and Phones
(windows, that is)
Gaming
2D Platforming
Multiplayer Games
Social Gaming
Game Engines comprados por Zynga y Disney:
Aves / RocketEngine
Gaming
CANVAS / WEBGL
HTML5 AUDIO
WEB SOCKETS
LOCAL STORAGE
ASM.JS
(javascript as c++)
THE GOOD PARTS
Prototype-Based / Multi-Paradigm
Dynamic / Safe Typing / First-Type Functions
C-Like Syntax (familiar to most of us)
Runs everywhere. Even on AR Drones
Google went nuts with V8
98% of code is OPEN SOURCE / FREE
First Type Functions
La habilidad que tiene un lenguaje de programación para tratar a las funciones como ciudadanos de "primera clase".
(a first-class citizen is an entity that can be constructed at run-time, passed as a parameter, returned from a subroutine, or assigned into a variable)
functions, functions, functions
Las funciones en Javascript son:
- Un método
- Una clase
- Un Constructor
- Un módulo
Function Statement
Esta declaración es un function statement:
Es igual a esta (function expression):
var hacerAlgo = function hacerAlgo() { }
Y a esta:
var hacerAlgo = function() { }
Function for class declaration
var ViewModel = function(){
var self = this;
this.nombre = ko.observable();
this.apellido = ko.observable();
}
//One way to do it
var miObjeto = new ViewModel();
//Another way to do it
var miOtroObjeto = Object.create(ViewModel);
//How NOT to do it
var miOtroObjeto = ViewModel();
Function as a module (IIFE)
//Variable global
var dinosaurio = 'velociraptor';
var ECOSISTEMA = new (function (){
var self = this;
self.dinosaurio = 'Trex';
return self;
})();
dinosaurio != ECOSISTEMA.dinosaurio;
prototypal inheritance
There are no classes in javascript, there's just objects:
A class definition is an object,
and an instance is also an object.
So inheritance is managed by
making objects inherit from objects