W2. Computation Flashcards
Describe the OG web model
- client sends request
- server returns page
- web pages stored in files on server
Everything is static!
Describe the modern web model
- dynamic content/input
- personalised data on pages
- can upload info from client to server (info in both directions)
- client-side state (asynch & caching)
- validation on client & server sides
- fetch new info dynamically
List technologies needed to create dynamic web pages
- Event handlers in HTML
- Handlers calling client-side JS
- JS manipulates the DOM
- Some language server-side (JS for code re-usability)
In JS, what does dynamic typing mean?
Type of a variable is assigned when the value is assigned
- type may also be changed if value is re-assigned
(but typing is strong)
In JS, what are the primitive types?
- numbers
- strings
- booleans
In JS, what are the trivial types?
- null
- undefined
In JS, what are the composite types?
- objects
- arrays
In JS, what properties do functions have as types?
- functions are first-class values
- there are multiple ways of defining functions
What is the difference between using == and === in JS?
== checks if two values are the same regardless of type (coercion to same type before comparison)
=== checks type as well as value - strict equality
(also used for strings)
What properties does the keyword “let” have in JS?
- to introduce a declaration
- smallest scope (block scope { } )
What properties does the keyword “var” have in JS?
- to introduce a declaration
- global/function scope
What properties does the keyword “const” have in JS?
- to introduce a declaration
- block scope { }
- cannot be updated - like final in Java
How are variables declared if let, var and const are NOT used?
Variable will be globally scoped
List 4 objects that are accessible via the JS DOM API
- document
- window
- navigator
- screen
Where in HTML should a script tag for JS be placed?
At the bottom of the page (just before