Last revised Feb 26, 2024, 10:00pm
<!DOCTYPE html> <html> <head> <title> <style> <meta> <link> <body> <span> <br> <hr> <strong> <em> <h1> <h2> <p> <ul> <ol> <li> <table> <tr> <th> <td> <img> <a> <form> <input> <label> <select> <option>
color background-color width height padding margin font-family font-size font-weight font-style
font border
red lime blue maroon green navy yellow aqua turquoise olive teal purple black white gray silver pastel red (pink) pastel green pastel blue
else false for function if let return true typeof var
boolean number object string undefined
Arithmetic: + - * / ** % Increment: ++ -- Comparison: == < <= > >= != !== Logical: && || Assignment: = += -= *= /= Miscellaneous: . [ ] ( ) { } typeof
forEach pop push reverse shift splice sort toString unshift
charAt indexOf lastIndexOf repeat toLowerCase toUpperCase trim
ceil floor random round
var name = "Larry", amt = "$245.81"; var s = `${name} owes me $${amt}.`;
JSON.stringify JSON.parse Example: kids = `[{"name": "Alice", "age" : 11}, {"name": "Bob", "age" : 9}]`; console(JSON.parse(kids)); // Output: [ { name: 'Alice', age: 11 }, { name: 'Bob', age: 9 } ]
require
> npm init > npm i (install module) > npx nodemon (start nodemon)
http-status-codes Object: StatusCodes
fs Methods: appendFile readFile writeFile
express Methods: express -- creates app object
express.static -- creates static folder
express app object methods:
app.listen app.get app.post app.set app.use
file __dirname path
Node request object (req or q) properties:
headers method headers
Node response object (res or r) methods:
end writeHead write
Express request object (req or q) properties:
body params query
Express response object (res or r) methods:
send sendFile render
Use render to pass data from main.js to an EJS page.
ejs EJS delimiters: <% ... %> <%= ... %>