require([...], function() { ..... function ABC () {a = c + b; } ..... });
Solved! Go to Solution.
In AMD style codes, I don't understand what happens when a function is in inside the require([...], function() {}); for example, the following codes:
require([...], function() { ..... function ABC () {a = c + b; } ..... });
The function ABC is very confusing to me. When the program runs, when will function ABC be executed? To understand this, should I go study more dojo language? Thanks a lot!
// ABCModule define([], function() { function ABC (b, c) { var a = c + b; return a; } return ABC; // defined modules should return something, object or function. }); // Main JS file require(['./ABCModule'], function(ABC) { ABC(1, 2); // returns 3; });
In AMD style codes, I don't understand what happens when a function is in inside the require([...], function() {}); for example, the following codes:
require([...], function() { ..... function ABC () {a = c + b; } ..... });
The function ABC is very confusing to me. When the program runs, when will function ABC be executed? To understand this, should I go study more dojo language? Thanks a lot!
// ABCModule define([], function() { function ABC (b, c) { var a = c + b; return a; } return ABC; // defined modules should return something, object or function. }); // Main JS file require(['./ABCModule'], function(ABC) { ABC(1, 2); // returns 3; });