Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ngarbezza
Last active October 2, 2019 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngarbezza/a0332ae693cede11155535636234813a to your computer and use it in GitHub Desktop.
Save ngarbezza/a0332ae693cede11155535636234813a to your computer and use it in GitHub Desktop.
Referencia Rápida Javascript
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