For example from this example:
export const ADD_TODO = \'ADD_TODO\'
export const DELETE_TODO = \'DELETE_TODO\'
export const EDIT_TODO = \'EDIT_TODO\'
export
This is more useful in other languages, but also somewhat useful in JavaScript. For instance, if I used "ADD_TODO"
throughout the code, instead of ADD_TODO
, then if I make a mistake typing any of the strings, if it was code like, if (action === 'ADD_TODOz')
, when that code executes, it will do the wrong thing. But if you mistyped the name of the const, if (action === ADD_TODOz)
, you'll get som kind of a ReferenceError: ADD_TODOz is not defined
when that line attempts to execute -- because ADD_TODOz
is an invalid reference. And, of course, in a static language, you'll get an error at "compile time."