General - JavaScript basics Flashcards
1
Q
Q: What is type coercion in JavaScript?
A
A: Automatic conversion between types (e.g., “5” + 2 → “52”)
2
Q
Q: Common JS variable types?
A
A: String, Number, Boolean, Undefined, Object
3
Q
Q: Two common string methods in JS?
A
A: .length, .toUpperCase(), .substring()
4
Q
Q: What does document.getElementById(“demo”) do?
A
A: Selects the element with id “demo” from the DOM.
5
Q
Q: What’s a JavaScript event handler example for a button?
A
A: <button>Click Me</button>