Js Flashcards
(6 cards)
1
Q
declare and assign variables
A
var x = 5; // Function-scoped
let y = 10; // Block-scoped
const z = 15; // Block-scoped, immutable
2
Q
user interaction dialogs
A
alert()
confirm()
prompts()
3
Q
event and event handler
A
event: action triggered by user and caught by browser
event handler; function that executes events
<input type = “button” value”click” onclick=”function()”/>
function(){alert(“clicked”);}
4
Q
Name common events.
A
click, mouseover, keydown, load, submit
5
Q
What’s the difference between onclick and addEventListener?
A
onclick overwrites existing handlers.
addEventListener allows multiple handlers:
6
Q
How do you change an element’s content?
A
document.getElementById(“demo”).innerHTML = “New content”;