In Javascript Harmony, we can for example do the following:
var maths = {
sum (...args) {
let r = 0;
for (let num of args) {
r += num;
}
return r;
}
};
maths.sqr = n => n * n;
I just wondered if there is any way to use an arrow function, like sqr within the object definition, just like sum.
var maths = { sqr : n => n * n; };Here you go.