nodejs定义函数的方法
2016-05-13 10:29
603 查看
test_163:/home/exenode/part3/module_exports # more calc.js
module.exports = {
sum:function() {
var result = 0;
for (var i in arguments) {
if (!isNaN(arguments[i])){
result += parseFloat(arguments[i]);
}
}
return result;
},
};
test_163:/home/exenode/part3/module_exports # more index.js
var calc = require('./calc');
console.log('calc:', calc.sum(1,20,34,-9,56));
test_163:/home/exenode/part3/module_exports #
test_163:/home/exenode/part3/module_exports # node index.js
calc: 102
module.exports = {
sum:function() {
var result = 0;
for (var i in arguments) {
if (!isNaN(arguments[i])){
result += parseFloat(arguments[i]);
}
}
return result;
},
};
test_163:/home/exenode/part3/module_exports # more index.js
var calc = require('./calc');
console.log('calc:', calc.sum(1,20,34,-9,56));
test_163:/home/exenode/part3/module_exports #
test_163:/home/exenode/part3/module_exports # node index.js
calc: 102
相关文章推荐
- 在windows环境下基于sublime text3的node.js开发环境搭建
- nodejs Stream使用手册——pipe
- nodejs 同步request
- Node.js入门——mac下安装Node.js
- NodeJs+Request+Cheerio 采集数据
- Leetcode 237. Delete Node in a Linked List
- HTML的DOM对象的nodeName
- Nodejs in Visual Studio Code 11.前端工程优化
- nodejs 建站
- Node.js 异步编程之 Callback介绍
- 那些年,在nodejs上踩过的坑
- nodejs 回调地狱解决 promise async
- Node.js的项目构建工具Grunt的安装与配置教程
- 【Node.js】使用iconv-lite解决中文乱码 (GB2312)
- VirtualBox,vagrant,ubuntu,nodejs环境搭建
- node.js的process进程和子进程
- 经典qq表情插件(html+nodejs应用)
- 整理一些前端开发比较好的node包
- 使用Node.js实现一个简单的ZooKeeper客户端
- node.js sream II