我正在创建自己的节点js结构,我正在使用express for http server。我也看到了很少的其他结构,如loopback和sails.js
他们还将一些对象分配给global
。
所以我有点困惑,如果我将使应用程序全球将它出现任何问题,如安全基础性能基础或这种方式的任何其他问题。
Before marking it negative please mention the reason in comment so that I will not repeat this mistake again
谢谢
答案 0 :(得分:0)
In my opinion, having 1 or couple of variables in global context is fine. Root global objects should be very few. Anything required globally should be inside those objects.
Many libraries on client side bind to global object like moment, lodash, async (That is only way to make your object available to others,I guess)