Test JS script file

Selected file: 03fun_parameter_callback.js
Compare console.log() outputs in browser and NodeJS.
Notice: Open browser's console in FireBUG!

  1. 01fun_definition.js
  2. 02fun_parameter_var.js
  3. 03fun_parameter_callback.js
  4. 03fun_parameter_callback2.js
  5. 03fun_parameter_callback3.js
  6. 05fun_var_in_global_scope.js
  7. 06fun_global_var_in_function.js
  8. 07fun_global_var_in_callback.js

..:: Source code - 03fun_parameter_callback.js ::..

/**
 * callback as function parameter
 */

//define function with callback
function fja(p1, cb) {
	
	res = p1 +10;
	cb(p1);
}


//define parameters
var x=2;

var cb1 = function(a) { //callback as a variable
	console.log(a);
}


//call function
var res = fja(x, cb1); //2
 

..:: NodeJS Console - 03fun_parameter_callback.js ::..

$ node 03fun_parameter_callback.js
2
$ps -aux | grep node (list all node processes)
sasa        1194  0.5  0.4 1303668 80732 ?       Ssl  Oct24 272:04 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa        1200  0.9  0.8 11723120 138632 ?     Ssl  Oct24 477:00 node /home/sasa/dex8/dex8-api/starter.js
sasa        1207  0.4  0.4 1304652 73284 ?       Ssl  Oct24 223:59 node /home/sasa/regoch/regoch-www/server
sasa        1208  0.3  0.4 1304912 73036 ?       Ssl  Oct24 195:04 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1224  0.9  0.6 11825936 103784 ?     Ssl  Oct24 470:13 node /home/sasa/dex8/dex8-www/server/index.js
sasa        1236  0.5  0.5 11811596 96752 ?      Rsl  Oct24 298:40 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1255  0.7  0.5 1330860 84396 ?       Ssl  Oct24 400:01 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js
sasa        1257  0.3  0.4 1301028 69132 ?       Ssl  Oct24 198:14 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1289  0.3  0.4 1297724 67172 ?       Ssl  Oct24 195:30 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1363  3.1  2.8 12164724 468016 ?     Ssl  Oct24 1665:35 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1449  0.3  0.3 1167336 65416 ?       Ssl  Oct24 204:54 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1528  1.7  2.6 33114568 441316 ?     Ssl  Oct24 907:29 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1529  0.3  0.3 1100644 64464 ?       Ssl  Oct24 204:44 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1606  0.3  0.3 1100132 63928 ?       Ssl  Oct24 204:47 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1607  0.3  0.4 1100900 65976 ?       Ssl  Oct24 204:11 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1705  0.3  0.4 1101416 65548 ?       Ssl  Oct24 204:06 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1706  0.3  0.3 1101412 64532 ?       Ssl  Oct24 204:02 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1805  0.3  0.4 1167200 66424 ?       Ssl  Oct24 204:16 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1807  0.3  0.3 1100384 64496 ?       Ssl  Oct24 200:07 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1885  0.3  0.3 1099624 63688 ?       Ssl  Oct24 201:27 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1886  1.6  0.9 11858512 161248 ?     Ssl  Oct24 872:13 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
sasa     2628167  0.8  0.7 1170068 127116 ?      Ssl  Nov04 301:46 node /home/sasa/voovuu/voovuu-api/starter.js
sasa     3168557  0.6  0.5 11822028 98212 ?      Ssl  Nov06 214:29 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa     3169051  0.4  0.5 11798408 83520 ?      Ssl  Nov06 140:03 node /home/sasa/@mikosoft/dodo-examples/server/index.js
www-data 3743771  0.0  0.0   2608   596 ?        S    19:46   0:00 sh -c ps -aux | grep node
www-data 3743773  0.0  0.0   3304   716 ?        S    19:46   0:00 grep node