-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nicolas Borboën
committed
Sep 12, 2014
1 parent
99d9fe6
commit a989c1b
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Simple test about function call | ||
*/ | ||
|
||
var http = require('http'); | ||
function my_test (req, res) { | ||
res.writeHead(200, {'Content-Type': 'text/html'}); | ||
|
||
// Call function 1 | ||
function_1(res); | ||
|
||
// call function 2 | ||
function_2(res); | ||
|
||
res.write('<br><br> Why are my functions called twice in console.log and only once in the browser ?'); | ||
res.end(); | ||
} | ||
|
||
|
||
http.createServer(my_test).listen(1337, '127.0.0.1'); | ||
console.log('Server running at http://127.0.0.1:1337/'); | ||
|
||
function function_1(res) { | ||
res.write('<br> -> function_1 called'); | ||
console.log(' -> function_1 called'); | ||
return true; | ||
} | ||
|
||
function function_2(res) { | ||
res.write('<br> -> function_2 called'); | ||
console.log(' -> function_2 called'); | ||
return true; | ||
} |