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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

user interaction dialogs

A

alert()
confirm()
prompts()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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”);}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Name common events.

A

click, mouseover, keydown, load, submit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What’s the difference between onclick and addEventListener?

A

onclick overwrites existing handlers.

addEventListener allows multiple handlers:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you change an element’s content?

A

document.getElementById(“demo”).innerHTML = “New content”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly