Alejandro Oviedo García
Alejandro is a developer who loves learning new things. He is passionate about education, electronics, Open Source, and community-driven events.
Standardization of the general purpose, cross platform, vendor-neutral programming language ECMAScript. This includes the language syntax, semantics, and libraries and complementary technologies that support the language.
Basically any new syntax (i.e. let, const, etc). Same goes with Proxies and Modules.
[1,2,3].forEach(function(x) { console.log(x + 1) }); // can be changed to
[1,2,3].forEach(x => console.log(x + 1));
(a, b) => {
//your code
}
var example = {
count: 0,
increment: function(){
setTimeout(function timeout() {
this.count++;
}, 1000);
}
}
example.increment();
var example = {
count: 0,
increment: function(){
var that = this;
setTimeout(function timeout() {
that.count++;
}, 1000);
}
}
example.increment();
var example = {
count: 0,
increment: function() {
setTimeout(() => this.count++, 1000);
}
}
example.increment();
var obj = {
// __proto__
__proto__: theProtoObj,
// Shorthand for ‘handler: handler’
handler,
// Methods
toString() {
// Super calls
return "d " + super.toString();
},
// Computed (dynamic) property names
[ 'prop_' + (() => 42)() ]: 42
};
var [d, m, a] = [21, 10, 2015];
//instead of var d = 21, m = 10, a = 2015;
x = 3; y = 4; [x, y] = [y, x]
// instead of temp = [y, x]; x = temp[0]; y = temp[1];
function now() { return [15, 5, 2014, 20, 0]; }
var [d, m] = now(); // m = 15, d = 5
var [,,year] = now(); // no need to accept all elements
function today() { return { d: 15, m: 5, y: 2014 }; }
var { m: month, y: year } = today(); // month = 5, year = 2014
var document = { timestamp: 1400077764803, latitude: -8.137003, longitude: -34.901167, prop1 ....prop999 }
function processDocument({ latitude: lat, longitude: long }) {
// do something here
}
Example:
for(var i = 0; i < 10; i++){
setTimeout(function(){
console.log(i);
}, 10);
}
let notExported = 'abc';
export function multiply(x) {
return x * MY_CONSTANT;
}
export const MY_CONSTANT = 7;
Another option is:
let notExported = 'abc';
function multiply(x) {
return x * MY_CONSTANT;
}
const MY_CONSTANT = 7;
export { multiply, MY_CONSTANT };
export { multiply as mult, MY_CONSTANT as ANOTHER_CONSTANT };
export { sha-1 as sha-1 } from 'lib/crypto'; // re-exports only sha-1
export * from 'lib/crypto'; // or re-export everything
import { multiply } from 'calc';
console.log(multiply(3));
import 'calc' as c;
console.log(c.multiply(3));
By Alejandro Oviedo García
Alejandro is a developer who loves learning new things. He is passionate about education, electronics, Open Source, and community-driven events.