Last active
October 2, 2019 21:33
-
-
Save ngarbezza/a0332ae693cede11155535636234813a to your computer and use it in GitHub Desktop.
Referencia Rápida Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var x = 3; // antigua declaracion de variables, pueden ser reasignadas | |
let y = 4; // actual declaracion de variables que pueden ser reasignadas | |
const z = 5; // actual declaracion de variables que NO pueden ser reasignadas | |
const string = `x es ${x}, y es ${y}, z es ${z}`; // los strings se pueden interpolar | |
// acceder al "parent" de un objeto | |
var lista = ['unas', 'cuantas', 'cosas']; | |
lista.__proto__; // prototipo de Array | |
lista.__proto__.__proto__; // prototipo de Object | |
lista.__proto__.__proto__.__proto__; // null (acá se termina la "cadena") | |
// igualdad no estricta (==) ojo! | |
// https://dorey.github.io/JavaScript-Equality-Table/ | |
0 == "0" // true | |
// igualdad estricta (===) | |
0 === "0" // false | |
// funciones "constructoras" de objetos | |
// 1. Antes de ECMAScript 2015 | |
function Persona(nombre, edad) { | |
this.nombre = nombre; | |
this.edad = edad; | |
this.saludar = function() { | |
return `hola! me llamo ${this.nombre}`; | |
} | |
} | |
// 2. Despues de ECMAScript 2015 | |
class Persona { | |
constructor(nombre, edad) { | |
this.nombre = nombre; | |
this.edad = edad; | |
} | |
saludar() { | |
return `hola! me llamo ${this.nombre}`; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment