330 likes | 506 Views
Introduction to Web Frontend Development with JavaScript. Network of Computer Networks. Internet. World Wide Web. The part of the Internet that communicates http and (often) html. HTTP. HyperText Transfer Protocol Client/Server Network Protocol
E N D
Network of Computer Networks Internet
World Wide Web The part of the Internet that communicates http and (often) html.
HTTP • HyperText Transfer Protocol • Client/Server Network Protocol • Requests are sent with Verbs to Resources • Get, Post, Put, Delete, Patch, Trace, Options • Responses are returned by the server with a status code • 200 OK, 404 Not Found, 301 Permanent Redirect
Web Development • is hard. • You must know at least 3 (often 4) programming languages: JavaScript the state and behavior of then frontend • CSS • how things look HTML structure of the UI/Document • Server Programming • Stateful storage and interaction with other servers
The Planetarium • Beautiful Web Introduction to the solar system • BananBread • Web FPS shoorter • CSS Tricks • Web Animation (using data from 3d body tracking)
Firefox Scratchpad Shift+F4
alert() • Modal window
prompt() • Rarely used. Modal window.
Shows in console console.log()
Let’s take a look at some syntax Syntax Reference
var • varaNumber = 1, • aString = "a string", • anArray = [1, 2, "string"], • anObject = {a: 1; b: "string", "c": 4};
If Statement • if ( /* something truthy */ ) { • //code to execute • } • else { • // code to execute • }
Switch Statement • switch (variable) { • case value1: • //statements • break; • case value2: • //more statements • default: • //more statements • break; • }
for loop • for (vari = 0; i < 5; i++) { • //statements • }
for … in • for (key in object) { • //statements • }
while loop • while (condition) { • statement; • }
do … while • do { • statement; • } while (condition);
Truthy • When a value will be “true enough” for an if (or while) condition.
Truthyvstrue • varobj = {}; • console.log("an empty object is not equal to true: " + (obj == true)); • if (obj) { • console.log("but it’s truthy"); • }
Two Concepts • A value that is not equal to true may still be truthy. • A value that is equal to true is truthy.
Truthiness • true • 1 • [1, 2] • {a: 1} • "something"
Falsiness • false • 0 • "" • NaN • undefined • null
== (equal) vs. === (strictly equal) Two comparison Operators
It checks whether the values can be coerced into the same type and then if their values become equal. == does type coercion
=== checks type and value ALWAYS use ===
==vs === • 1 == 1 • true • 1 == "1" • true • 1 == true • true • 0 == false • true • 1 === 1 • true • 1 === "1" • false • 1 === true • false • 0 === false • false