1. Data Structures
Data Structures allow us to store and organize data efficiently. This makes us access and performs operations on the data smoothly.
In JavaScript, we have built-in Data Structures like,
- Arrays
- Objects
- Maps
- Sets
2. Array
An Array holds an ordered sequence of items.
2.1 Creating an Array
JAVASCRIPT
2.2 Accessing an Array Item
JAVASCRIPT
2.3 Modifying an Array Item
JAVASCRIPT
2.4 Finding Array Length
The
array.length
is used to find the number of items in the array.JAVASCRIPT
2.5 Array Methods
2.5.1 push()
The
push()
method adds new items to the end of the array.JAVASCRIPT
2.5.2 pop()
The
pop()
method removes the last item of an array and returns that item.JAVASCRIPT
Try out creating an array, accessing, modifying its array items, and apply array methods to them in the below Code Playground.
3. Functions
3.1 Function Declaration
JAVASCRIPT
3.2 Function Expression
There is another syntax for creating a function which is called Function Expression.
JAVASCRIPT
4. More DOM Manipulations
4.1 Creating an HTML Element - createElement()
JAVASCRIPT
4.2 Appending to an HTML Element - appendChild()
Appending to Document Body Object:
JAVASCRIPT
Appending to Existing Container Element:
JAVASCRIPT
Try out creating and appending the HTML elements like a paragraph, image, etc. in the below Code Playground.
4.3 Adding Event Listeners Dynamically
JAVASCRIPT
4.4 Providing Class Names Dynamically - classList.add()
JAVASCRIPT
CSS
4.5 Removing Class Names Dynamically - classList.remove()
JAVASCRIPT
Try out adding the event listeners, class names and removing class names dynamically in the below Code Playground.