Jul 21, 2024
const
- declares a constant variable.let
- declares a block-scoped local variable.var
- declares a function-scoped or globally-scoped variable.Arithmetic operators:
+
(addition)-
(subtraction)*
(multiplication)/
(division)%
(modulus)Assignment operators:
=
(assignment)+=
(addition assignment)<input type="button">
<input type="button" value="Click me">
const animals = ['cat', 'dog', 'elephant'];
document.getElementById()
.let element = document.getElementById('myElement');
element.innerText = 'Hello, world!';
Concepts of OOP:
Example of a class in Javascript:
class Employee {
constructor(name, position, salary) {
this.name = name;
this.position = position;
this.salary = salary;
}
getDetails() {
return `${this.name} is a ${this.position} earning ${this.salary}`;
}
}