M
M
Michael2017-03-23 01:43:26
Node.js
Michael, 2017-03-23 01:43:26

What's the best way to code in node.js?

Hello. There are two spellings. Which one is more correct?

const myModule = require('./libs/module');

//вариант первый
function func (one, two) {
  //some code
  let a = myModule.func(one);
  //some code
  let b = myModule.someFunc(two)
}
func(1, 2);

//вариант второй
function func (one, two, myModule) {
  //some code
  let a = myModule.func(one);
  //some code
  let b = myModule.someFunc(two)
}
func(1, 2, myModule);

That is, do I need to pass the variable in which I saved the module to the func function in similar situations? If so, then in some cases I will have to pass 6-7 variables to the function (in large projects). And how then to be?
Maybe I'm doing something wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Belyaev, 2017-03-23
@mak_ufo

IMHO...

const {func, someFunc} = require('./libs/module');

//вариант первый
function myfunc (one, two) {
  //some code
  let a = func(one);
  //some code
  let b = someFunc(two)
}
myfunc(1, 2);

A
Alexander Aksentiev, 2017-03-23
@Sanasol

www.jslint.com
jshint.com

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question