Please enable JavaScript.
Coggle requires JavaScript to display documents.
NodeJS & JQuery Tutorial (Functionalities of JQuery (The HTML setting…
NodeJS & JQuery Tutorial
Functionalities of NodeJS
It can make your computer to be a server instantly, and print contents on the web page doesn't require you to build any script (simple version response)
-
Writing a header is for the HTML deployment, and should include code and Content-Type.
If you didn't pass the .listen(<port>)
in the end of http.createServer(...)
function, then the node won't run the server...
Variable types
const
Also block scope, and prevent re-assignment and re-declaration
But not protection object key-value change (adding, pushing)
var
global scope, and very flexible (can be an issue)
let
block scope, and using { } to separate scopes
-
Javascript
Promise
-
Advantages:
We can do things in natural order: first run function to get the promise, and .then
we can do something.
-
-
-
When creating a Promise, the resolve function will return result, and reject function will handle new Error.
In html, you can use on... events to pre set when will this function been called
-
We can delay
setTimeout(() => resolve(...), 1000)
-
-
-
-
-
Arrow Functions
Parenthesis
0 arg: ()
1 arg: arg
2+ args: (arg1, arg2, ...)
:red_flag: If we only have one line of express and the return statement and bracket is omitted, then arrow function will automatically return result from this line of execution.
-
Notice that parameters are defined when we declare a function, whereas arguments are the actual values passed to functions when we invoke them.
Functions are objects
Because it is not one of the primitives (boolean, number, string, null, undefined)