fork download
  1. process.stdin.resume();
  2. process.stdin.setEncoding('utf8');
  3.  
  4. const createAction = (type, payload) =>({type,payload});
  5.  
  6. const a = {y:{x:"Hello"}};
  7. console.log(createAction("Hello", a));
  8.  
  9. const handle = (state, action) => Object.assign({}, state, action.payload);
  10.  
  11. console.log(handle({y:{x:'asd'}},undefined));
Runtime error #stdin #stdout #stderr 0.08s 26464KB
stdin
Standard input is empty
stdout
{ type: 'Hello', payload: { y: { x: 'Hello' } } }
stderr
/home/8TSVML/prog.js:9
const handle = (state, action) => Object.assign({}, state, action.payload);
                                                                 ^

TypeError: Cannot read property 'payload' of undefined
    at handle (/home/8TSVML/prog.js:9:66)
    at Object.<anonymous> (/home/8TSVML/prog.js:11:13)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:420:7)
    at startup (bootstrap_node.js:139:9)