JavaScript_Exam_Summary
JavaScript_Exam_Summary
1. Introduction to JavaScript
Definition: A scripting language for creating interactive web pages.
Purpose:
Comments:
- Single-line: // Comment.
Variables:
Example:
let name = "John";
Operators:
- Arithmetic: +, -, *, /, %.
4. Data Types
Primitive Types: Number, String, Boolean, Undefined, Null.
Complex Types:
5. Control Structures
Conditional Statements:
Loops:
Example:
6. Functions
Declaration: function name(parameters) { ... }.
Arrow Functions:
Example:
Built-in Functions:
- alert(), confirm(), prompt().
- document.write(), console.log().
7. DOM Manipulation
Selectors:
- document.getElementById("id").
- document.querySelector(".class").
Events:
Example:
document.getElementById("demo").innerHTML = "Text";
document.body.style.backgroundColor = "blue";
Document Object: Represents the HTML content and provides methods for manipulation.
Example:
Example:
Validation Example:
123
Number("123") Explicitly converts "123" to the number 123.
(number)