JS
JS
📌 Selecting Elements
📌 Manipulating Elements
Common Events:
Event Description
🔹 4. Timer Methods
js
Copy code
🔹 5. String Methods
Method Description
"Hello".toUpperCase
Converts to uppercase.
()
"Hello".toLowerCase
Converts to lowercase.
()
"Hello".indexOf
Finds the position of "e".
("e")
"Hello".replace ("H",
Replaces "H" with "J".
"J")
"Hello".substring(1,
Extracts "ell".
4)
🔹 6. Array Methods
Method Description
array.splice(index, deleteCount,
Removes/adds items.
newItems...)
🔹 7. Math Methods
Method Description
Math.round(4.6) Rounds to 5.
Math.ceil(4.1) Rounds up to 5.
Math.max(5, 10,
Returns 15.
15)
Math.min(5, 10,
Returns 5.
15)
🔹 8. Date Methods
Used to work with dates and times.
🔹 9. JSON Methods
Example:
Js code
document.write(5 + 6);
Using document.write() after an HTML document is loaded, will delete all existing HTML:
the window.print() method in the browser to print the content of the current
window.
Featu CS Programming
re HTML S Language?
Synta ✅
✅ Yes ✅ Yes
x Yes
Computations
❌ No ❌ No ✅ Yes
(2+2)
Conditionals (if-
❌ No ❌ No ✅ Yes
else)
Loops (for,
❌ No ❌ No ✅ Yes
while)
Functio ❌
❌ No ✅ Yes
ns No
Turing
❌ No ❌ No ✅ Yes
Complete?
const Yes No No No No
Constant Objects and Arrays
The keyword const is a little misleading.
It does not define a constant value. It defines a constant reference to a value.
Because of this you can NOT:
Reassign a constant value
Reassign a constant array
Reassign a constant object
But you CAN:
Change the elements of constant array
Change the properties of constant object
Operator Description
+ Addition
- Subtraction
* Multiplication
/ Division
++ Increment
-- Decrement
= x=y x=y
+= x += y x=x+y
-= x -= y x=x-y
*= x *= y x=x*y
/= x /= y x=x/y
%= x %= y x=x%y
**= x **= y x = x ** y
Operat Description
or
== equal to
!= not equal
? ternary operator
Operat Description
or
&& logical and
|| logical or
! logical not
Operator Description
= x=y x=y
+= x += y x=x+y
-= x -= y x=x-y
*= x *= y x=x*y
/= x /= y x=x/y
%= x %= y x=x%y
**= x **= y x = x ** y
^= x ^= y x=x^y
|= x |= y x=x|y
||= x ||= y x = x || (x = y)
??= x ??= y x = x ?? (x = y)
75—
1. 1-
2. 2-
3. 3
4. -4
5. -5
6. -6
7. -7
8. -8-
9. let
10. Const
11.