Skip to content
Marlbridge

Flashcards · 9626 · A Level Topic 21

Programming for the web (A Level) flashcards

10 cards on A Level Topic 21. Pick a subtopic or study them all.

Study mode needs JavaScript. Every card is listed below, so you can still cover the answers and test yourself.

All 10 cards

For a quick read-through or printing. Cover the right-hand side to test yourself.

Topic 21: Programming for the web

How is JavaScript added to a web page?
Inside a script element in the HTML, or in an external .js file linked using the script element's src attribute.
What is a variable in JavaScript, and how is it declared?
A named store whose value can change, declared with let, const or var.
Literal vs expression
A literal is a fixed value written in the code, such as 7, "Lahore" or false. An expression is values and operators that work out to one value, such as price * qty.
What is a JavaScript array, and where does its index start?
An ordered list in square brackets. The first index is 0.
What do alert, confirm and prompt return?
alert shows a message with OK and returns nothing useful. confirm returns true (OK) or false (Cancel). prompt returns the typed string, an empty string if nothing is typed, or null on Cancel.
When do onload, onchange, onclick and onkeydown fire?
onload: when the page or image finishes loading. onchange: when a value changes (a text box fires when it loses focus). onclick: when the element is clicked. onkeydown: when a key is pressed.
Name four ways JavaScript can display data
innerHTML, document.write(), window.alert() and console.log().
How do you change an element's style with JavaScript?
document.getElementById(id).style.property = new value, e.g. setting style.display or style.visibility to show or hide it.
setTimeout vs setInterval
setTimeout runs a function once after a delay. setInterval runs it repeatedly at a fixed interval until cleared.
What is a JavaScript event?
Something that happens to an HTML element, such as a click or a page loading, which can trigger code.