Node.js是一个运行javascript的环境,NodeJS的作者创造NodeJS的目的是为了实现高性能Web服务器。
Node.js® is a JavaScript runtime built on Chrome’s V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js’ package ecosystem, npm, is the largest ecosystem of open source libraries in the world.
—— Node.js官网
这篇文章主要摘录一些个人认为的重点,希望加深对Node.js的熟悉。
一、Node.js基础
exports 对象
exports对象是当前模块的导出对象,用于导出模块公有方法和属性。别的模块通过require函数使用当前模块时得到的就是当前模块的exports对象。以下例子中导出了一个公有方法。