fac-14 / teamcoolerweek-2

To-do-list project
1 stars 1 forks source link

module exports #31

Open morkeltry opened 6 years ago

morkeltry commented 6 years ago

Nothing to change here - just an explanation. This code at the bottom of logic.js :

 if (typeof module !== 'undefined') {
    module.exports = todoFunctions;
  }

essentially checks whether it is begin run in frontend or backend. ES5 in the browser does not recognise module / module.exports - in the browser you don't totally need it as you can import scripts from HTML. So without checking if (typeof module !== 'undefined'), referring to module would risk an error.

sbinlondon commented 6 years ago

Good to know - thank you for the explanation @morkeltry 😊