node. JS scope

conanma 2022-06-23 17:48:03 阅读数:875

node.nodejsscope

1. Scope

because node.js Functions are automatically encapsulated at execution time , Therefore, user-defined variables or functions are local . To share data with other modules , have access to :

// expose
module.exports
// Global variables
global
Can be omitted when using global

Such as :

var username = "liubai";
// module.exports.name = username;
// name = username;
global.name = username;
版权声明:本文为[conanma]所创,转载请带上原文链接,感谢。 https://qdmana.com/2022/01/202201051847395045.html