Suppose I have two files: 1.js and 2.js
In the first file, in the callback, I call the function from the second:
... var json = JSON.stringify({}); 2.someFunction(json); ...
Why in this case in the second file in the function I get undefined ?
Suppose I have two files: 1.js and 2.js
In the first file, in the callback, I call the function from the second:
... var json = JSON.stringify({}); 2.someFunction(json); ...
Why in this case in the second file in the function I get undefined ?
1.js:
var f1 = function() { return function(message) { console.log('i am new function, created inside function from 1.js') console.log(String(message)); } } module.exports = f1(); 2.js:
var f1 = require('./1'); (function somefunc(callback, message) { callback(message); })(f1, 'this string from 2.js'); 1.js:
var f1 = function() { console.log('1.js'); } module.exports = f1; 2.js:
var f1 = require('./1'); (function somefunc(callback) { callback(); })(f1); node 8.4.0
Source: https://ru.stackoverflow.com/questions/723477/
All Articles