[1,2].reduce((accum,val) => ({val}) ,{})
I expect above reduce function will return {1:1, 2:2} but it didn't, what's wrong? isn't I've return an object?
You need to spread the accumulator (working with newer JS or with babeljs) and computed property names.
console.log([1, 2].reduce((accum, val) => ({ ...accum, [val]: val }), {}));
One option is using Object.assign to add new property and values
var result = [1, 2].reduce((accum, val) => Object.assign(accum, {[val]: val}), {})
console.log(result);
Doc: Object.assign