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
class Rectangulo{ | |
constructor(alto,largo){ | |
this.alto = alto; | |
this.largo = largo; | |
} | |
getArea(){ | |
return this.alto * this.largo; | |
} |
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
//los mapas | |
let mapa = new Map(); | |
mapa.set("nombre","sebastian"); | |
mapa.set("edad",21); | |
console.log(mapa); //{"nombre" => "sebastian"} {"edad" => 21} | |
//inicializandolo con valores | |
let mapa2 = new Map( [ ["nombre","sebastian"] , ["edad",21] ]); | |
console.log(mapa2); //{"nombre" => "sebastian"} {"edad" => 21} |
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
let items = new Set([1, 2, 3, 4, 5, 5, 5, 5, 5, 5]); | |
console.log(items); //Resultado 1,2,3,4,5 | |
items.delete(3);//Resultado 1,2,4,5 | |
//items.clear(); borra todo | |
let numerosArray = [1,2,3,4,4,4,4,4,]; | |
//con una funcion anonima limpie el arreglo de los repetidos | |
var clean = (num => [... new Set(num)])(numerosArray); | |
console.log(clean);//Resultado 1,2,3,4 |
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
let items = new Set([1, 2, 3, 4, 5, 5, 5, 5, 5, 5]); | |
console.log(items); //Resultado 1,2,3,4,5 | |
items.delete(3);//Resultado 1,2,4,5 | |
//items.clear(); borra todo | |
let numerosArray = [1,2,3,4,4,4,4,4,]; | |
//con una funcion anonima limpie el arreglo de los repetidos | |
var clean = (num => [... new Set(num)])(numerosArray); | |
console.log(clean);//Resultado 1,2,3,4 |
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
//Parametros REST | |
function agregar_alumnos(arr_alumnos, ...alumnos) { | |
for (alum of alumnos) { | |
arr_alumnos.push(alum); | |
} | |
return arr_alumnos; | |
} | |
let arr_alumnos = ["Sebastian"]; | |
let result = agregar_alumnos(arr_alumnos, "scarlet", "seba jr", "scarlet jr"); | |
console.log(result);// Resultado = ["Sebastian", "scarlet", "seba jr", "scarlet jr"]. |
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
//Funcion normal | |
var suma1 = function (valor) { | |
return valor + valor; | |
} | |
console.log(suma1(1));//Resultado = 2 | |
//Funcion EC6 | |
let suma2 = valor => valor + valor; | |
console.log(suma2(1));//Resultado = 2 |
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
let saludar = nombre => { | |
let salida = `hola, ${nombre}`; | |
return salida; | |
} | |
console.log( saludar('sebastian') );//Result Hola Sebastian. |
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
Codigos hechos en JavaScript por Sebastian Medina | |
1)"Problema del caballo" con un caballo logro recorrer el tablero de ajedrez completo (sin modelo matematico) | |
https://jsfiddle.net/sebastian007/a66rb1k7/45/ | |
2)Escribir por pantalla Asincronamente | |
https://jsfiddle.net/sebastian007/hs10fkhn/29/ | |
3)Seccionar una cantidad numerica en distintas partes. | |
https://jsfiddle.net/sebastian007/j02quhm9/13/ |