Why in the beginning of the script write var app = app || {}; var app = app || {}; ? Link to the entire file .

PS Is it possible to connect JSX scripts (so that they work later) without the help of third-party libraries? For example, through <script type="text/jsx"></script> ?

  • 2
    Please correct the title, otherwise it is not informative at all. In PS, you seem to have a new question. - 0xdb
  • one
    For PS - no, it is impossible. - YozhEzhi

1 answer 1

var app = app || {};

Thus, overriding an object that has already been initialized is avoided when multiple loads of different application modules are loaded.

Equivalent:

 if (!window.app) { // Если app не определена window.app = {}; // Инициализируем её объектом } 

The remaining scripts will work with an already defined object, expanding and complementing it.