I hereby claim:
- I am ianaya89 on github.
- I am ianaya89 (https://keybase.io/ianaya89) on keybase.
- I have a public key whose fingerprint is CC95 CEE3 B67B E98F 11FF 4493 E628 369C 5247 E538
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
Blocking methods execute synchronously and non-blocking methods execute asynchronously. | |
Using the File System module as an example, this is a synchronous file read: | |
const fs = require('fs'); | |
const data = fs.readFileSync('/file.md'); // blocks here until file is read | |
And here is an equivalent asynchronous example: | |
const fs = require('fs'); | |
fs.readFile('/file.md', (err, data) => { |
// let | |
if(true) { | |
var a = 'a'; | |
let b = 'b'; | |
console.log(b + ' is available' ); | |
} | |
console.log(a); // ✅ | |
console.log(b); // ❌ => ReferenceError: b is not defined |
const fakeTitles = [ | |
'Pirate Of Reality', | |
'Guardians Of Hell', | |
'Witches With Vigor', | |
'Spies And Heroes', | |
'Robots And Kings', | |
]; | |
// Nueva Sintaxis | |
const abbreviations = fakeTitles.map(title => title.toLowerCase().slice(0, 3)); // ES6 |
// properties | |
const name = 'Ignacio'; | |
const age = 27; | |
const person = { name, age }; // ES6 | |
const person = { name: name, age: age }; //ES5 | |
// methods | |
const dog = { | |
bark() { |
// Object | |
const myObj = {a: 'a', b: 'b', c: 'c'}; | |
const {a, c} = myObj; | |
console.log(a); // => a | |
console.log(c); // => c | |
// Array | |
const [d, m, a] = [21, 10, 2015]; |
// asignar parametros a funcion | |
function getVolume(width, height, depth) { | |
return width * height * depth; | |
} | |
const values = [10, 20, 30]; | |
console.log(getVolume(...values)); // => 6000 | |
// concatenar arrays | |
const array1 = [1, 2, 3]; |
// variables | |
const foo = 'bar'; | |
const bizz = 'bang'; | |
console.log(`Foo is ${foo} and bizz is ${bizz}`); // => 'Foo is bar and bizz is bang' | |
// llamadas de funciones | |
function hello() { | |
return 'hello'; | |
} |
function foo(x = 11, y = 31) { | |
console.log( x + y ); | |
} | |
foo(); // 42 | |
foo( 5, 6 ); // 11 | |
foo( 0, 42 ); // 42 | |
foo( 5 ); // 36 |
const map = new Map(); | |
map.set('foo', 123); | |
map.get('foo') // 123 | |
map.has('foo') // true | |
map.set(10, 'Something...'); | |
map.get(10) // Something... | |
map.has(10) // true |