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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<div id="container"></div> | |
</body> |
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
const arr = ['a', 'b', 'c']; | |
const iterador = arr[Symbol.iterator](); | |
iterador.next(); | |
// { value: 'a', done: false } | |
iterador.next(); | |
// { value: 'b', done: false } | |
iterador.next(); | |
// { value: undefined, done: true } | |
/// Only for linear data strutures |
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
(function() { | |
var CSS_CLASS_DELIM, QuickdrawError, VirtualDomNode, dispatchEvent, exports, qd, qdInternal, | |
slice = [].slice, | |
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, | |
hasProp = {}.hasOwnProperty; | |
qd = {}; | |
if (typeof window !== "undefined" && window !== null) { | |
if (window.qd != null) { |
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
// Promesas (Promises) ES6 | |
// XHR request XMLHttpRequest | |
// cross domain request | |
// https://www.mocky.io/ | |
function request(url){ | |
return new Promise((resolve, reject) => { | |
var xhr = new XMLHttpRequest(); | |
xhr.open('GET', url); |
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
function random(){ | |
return Math.floor(Math.random() * 10); | |
} | |
function getJSON() { | |
return new Promise(function (resolve, reject) { | |
setTimeout(() => resolve('Yes'),random()); | |
setTimeout(() => reject('No'), random()); | |
}); | |
} |
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
/* jshint esnext: true */ | |
// getters y setters | |
var persona = { | |
name: 'alejandro', | |
lastname: 'amador', | |
get fullname() { | |
return `${this.name} ${this.lastname}` | |
}, | |
set fullname(fullvalue) { |
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
/* jshint esnext: true */ | |
function Element(tipo) { | |
this.element = document.createElement(tipo); | |
} | |
Element.prototype.destroy = function(){ | |
var parent = this.element.parentNode; | |
parent.removeChild(this.element); | |
this.element = null; | |
} |
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
/* jshint esnext: true */ | |
// class ES6 | |
class Button { | |
constructor(label, callback) { | |
this.label = label; | |
this.callback = callback; | |
this.html = this.createHTML(); | |
this.bindEvents(); | |
} | |
onClick() { |
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 a = { | |
valor: 'Hola' | |
}; | |
var b = { | |
proto: a | |
}; | |
var c = { | |
proto: b | |
}; |
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
function objectCreate(o) { | |
function Helper() {} | |
Helper.prototype = o; | |
return new Helper(); | |
} |