HTML, CSS and JavaScript, JSON Flashcards
What is JavaScript?
An OOP language supported by all browsers, used to program behaviour of web-pages on the occurrence of an event/in response to user interaction
What is HTML?
A language for creating web pages. Describes the structure of a web page and is used alongside other styling languages to design the layout of a webpage
- HTML annotations are realised through tags (names enclosed in angle brackets)
What is CSS?
Cascading Style sheets: A style sheet language for describing the look and formatting of a document written in HTML.
- can combine CSS and HTML by adding it in as a link to a stylesheet file that holds css
What was developed for running javascript?
Node.js which can be run in the CLI. Originally you could only run Javascript in a web browser console. Then Node.JS was developed.
What is Node.JS?
A javascript runtime, which allows you to run javascript on a server or your laptop
List the Javascript primitive types:
Undefined, Null, Boolean, Number, String, Symbol, BigInt
Describe the javascript undefined type:
Give an example:
A variable that has not been assigned a value is of this type
- it’s the value returned from a function that doesn’t explicitly return anything
- trying to access a non-existing object property also returns undefined
let x;
console.log(x); //outputs undefined
Describe the javascript null type:
Give an example:
- Used to represent the intentional absence of any object value
- often used to represent a ‘no-value’ or ‘no-object’ state
- it needs to be assigned explicitly
let y = null;
console.log(y) returns null
Describe the javascript Boolean type:
- consists of two values: true and false
- used to represent logical values
Describe the javascript Number type:
- Represents numeric values
- used to represent both integers and floating point numbers
Describe the javascript String type:
Uses to represent textual data
Describe the javascript Symbol type:
- Used to create unique identifiers for objects
Describe the javascript BigInt type:
- Used to represent integers of arbitrary length
What are JavaScript expressions?
Give an example:
- Any valid unit of code that resolves to a value
- They can be used wherever JavaScript expects a value
e.g.
- 2 + 2
- “Hello” + “World”
- console.log(“Phoebe”)
What are Javascript Statements?
Give an example:
- A statement performs an action
- they control program flow and can contain expressions
E.g.
- var x = 10;
- if (x > 10) {…}
- for (var i = 0; i < 10; i++) {…}
What is the difference between Javascript expressions and statements?
While expressions always produce a value, statements may not.
- statements often contain expressions but the reverse is not true
- semicolons are used to separate expressions
Describe the JavaScript Let keyword:
- Used to declare a variable
- Has block scoping
- Let variables can be updated but not re-declared
- let is more modern (compared to var) and is generally the preferred choice for variable declaration due to block scoping
What is Block Scoping in JavaScript?
This means that a variable only exists within the block it’s declared in.
- variables declared with Let or const are scoped to the block
Describe the JavaScript Var keyword:
- Used to declare variables
- old alternative to let
- is function-scoped
What is function-scoping in JavaScript?
Variables declared with var inside a function are scoped to the function
What do HTML tags define?
- elements that represent aspects of a webpage (headings, images, text)
- elements can nest within each other creating a structured document
What is the DOM?
The Document Object Model is a programming interface for web documents
- it represents the structure of a document
- it allows programs to manipulate the documents structure, style and content
When the DOM is updated the web page automatically rerenders
How does the DOM represent a document
As a tree of objects
- HTML tags become nodes in the tree and these nodes can be manipulated using JavaScript
Describe HTML element attributes:
- HTML elements can have attributes, these provide information about the element. Common include attributes:
- Class: mostly used to point to a class in the stylesheet, can also be used by javascript to access/manipulate all elements of a specific class
- ID: specifies a unique id for an element, can be pointed to in the stylesheet or manipulated by javascript
- Style: specifies inline CSS style for an element