JavaScript, qué hermoso eres
</ironyOff>
Disclaimer
● JavaScript a la antigua usanza, nada de ES6.
● Spanglish
● Sólo sé que no sé nada.
Show me the code
https://github.com/islomar/poc-javascript/tree/master/alea-technical-friday
Sumario
1. Show and hide
2. Hoisting
3. Ola k ase, soi un numero o k ase
4. La globalización de las variables
5. Objetos
6. IIFE
7. Module pattern
8. Herencia y prototipado
9. Invocation patterns
Show and hide
Visto por ahí: uso de clase ‘hide’
jQuery ofrece funciones show(), hide() y toggle()
Hoisting
● Hoisting = elevar, alzar, levantar
● It is a concept about program load order
● Function expressions vs function declaration/statements.
○ Function expression:
■ var showMeTheMoney = function(){}
■ Never hoisted
■ It loads only when this particular line of code is reached while executing.
○ Function declaration/statements:
■ Builds in memory immediately when the program loads
■ It does not require variable assignment
■ Can be invoked during execution before its actual definition
Ola k ase, soi un numero o k ase
Using NaN to check if values are actually JS Numbers seems like
a good idea, but it will try to kill you.
La globalización de las variables
Global variable: a variable visible in every scope.
Possible collisions when programs grow...
JS makes it easy to define global variables that can hold all of the assets of your
application.
Objetos
● The simple types of JS are numbers, strings, booleans, null and undefined
● All other values are objects: arrays, functions, regular expressions, etc.
● Numbers, strings and booleans have methods but they are immutable.
● Objects are mutable keyed collections.
● Objects are class-free
IIFE
IIFE (Immediately Invoked Function Expression) is a JavaScript function that runs as
soon as it is defined.
Used to hide “private” properties: module pattern.
Module pattern
The Module pattern is used to further emulate the concept of classes in such a way
that we're able to include both public/private methods and variables inside a single
object, thus shielding particular parts from the global scope.
What this results in is a reduction in the likelihood of our function names conflicting
with other functions defined in additional scripts on the page.
Inheritance and protoyping
● JS is a prototypal language, which means that objects inherit directly from other
objects.
● Every object is linked to a prototype object from which it can inherit properties.
● All objects created from object literals are linked to Object.prototype.
● When you make a new object, you can select the object that should be its
prototype.
Invocation patterns
● Invoking a function suspends the execution of the current function, passing
control and parameters to the new function.
● In addition to the declared parameters, every function receives two additional
parameters, every function receives two additional parameters: ‘this’ and
arguments.
Invocation patterns
● The patterns differ in how the bonus parameter ‘this’ is initialized:
○ Method invocation pattern
○ Function invocation pattern
○ Constructor invocation pattern
○ Apply invocation pattern
Bibliografía recomendada
● https://developer.mozilla.org/en-US/docs/Web/JavaScript
● Head First JavaScript
● CodeSchool: JavaScript Path
● JavaScript The Good Parts (Douglas Crockford)
● JavaScript Enlightenment (Cody Lindley)
JavaScript, qué hermoso eres

JavaScript, qué hermoso eres

  • 1.
    JavaScript, qué hermosoeres </ironyOff>
  • 2.
    Disclaimer ● JavaScript ala antigua usanza, nada de ES6. ● Spanglish ● Sólo sé que no sé nada.
  • 3.
    Show me thecode https://github.com/islomar/poc-javascript/tree/master/alea-technical-friday
  • 4.
    Sumario 1. Show andhide 2. Hoisting 3. Ola k ase, soi un numero o k ase 4. La globalización de las variables 5. Objetos 6. IIFE 7. Module pattern 8. Herencia y prototipado 9. Invocation patterns
  • 5.
    Show and hide Vistopor ahí: uso de clase ‘hide’ jQuery ofrece funciones show(), hide() y toggle()
  • 6.
    Hoisting ● Hoisting =elevar, alzar, levantar ● It is a concept about program load order ● Function expressions vs function declaration/statements. ○ Function expression: ■ var showMeTheMoney = function(){} ■ Never hoisted ■ It loads only when this particular line of code is reached while executing. ○ Function declaration/statements: ■ Builds in memory immediately when the program loads ■ It does not require variable assignment ■ Can be invoked during execution before its actual definition
  • 7.
    Ola k ase,soi un numero o k ase Using NaN to check if values are actually JS Numbers seems like a good idea, but it will try to kill you.
  • 8.
    La globalización delas variables Global variable: a variable visible in every scope. Possible collisions when programs grow... JS makes it easy to define global variables that can hold all of the assets of your application.
  • 9.
    Objetos ● The simpletypes of JS are numbers, strings, booleans, null and undefined ● All other values are objects: arrays, functions, regular expressions, etc. ● Numbers, strings and booleans have methods but they are immutable. ● Objects are mutable keyed collections. ● Objects are class-free
  • 10.
    IIFE IIFE (Immediately InvokedFunction Expression) is a JavaScript function that runs as soon as it is defined. Used to hide “private” properties: module pattern.
  • 11.
    Module pattern The Modulepattern is used to further emulate the concept of classes in such a way that we're able to include both public/private methods and variables inside a single object, thus shielding particular parts from the global scope. What this results in is a reduction in the likelihood of our function names conflicting with other functions defined in additional scripts on the page.
  • 12.
    Inheritance and protoyping ●JS is a prototypal language, which means that objects inherit directly from other objects. ● Every object is linked to a prototype object from which it can inherit properties. ● All objects created from object literals are linked to Object.prototype. ● When you make a new object, you can select the object that should be its prototype.
  • 13.
    Invocation patterns ● Invokinga function suspends the execution of the current function, passing control and parameters to the new function. ● In addition to the declared parameters, every function receives two additional parameters, every function receives two additional parameters: ‘this’ and arguments.
  • 14.
    Invocation patterns ● Thepatterns differ in how the bonus parameter ‘this’ is initialized: ○ Method invocation pattern ○ Function invocation pattern ○ Constructor invocation pattern ○ Apply invocation pattern
  • 15.
    Bibliografía recomendada ● https://developer.mozilla.org/en-US/docs/Web/JavaScript ●Head First JavaScript ● CodeSchool: JavaScript Path ● JavaScript The Good Parts (Douglas Crockford) ● JavaScript Enlightenment (Cody Lindley)