JavaScript Concepts with Exercises and Documentation
Resources for MERN Stack
Below is a curated list of essential JavaScript concepts, exercises, and helpful
resources to prepare for the MERN stack.
1. JavaScript Basics
Topics to Cover:
Variables ( var , let , const )
Data types: String, Number, Boolean, Object, Array, Undefined, Null
Operators: Arithmetic, Logical, Comparison, Assignment
Control structures: if , else , switch-case , loops ( for , while , do-while )
Exercises:
1. Write a program to check if a number is positive, negative, or zero.
2. Create a loop that prints numbers from 1 to 10.
3. Use a switch-case to print the day of the week based on a number.
Resources:
MDN: JavaScript Basics
JavaScript.info: Fundamentals
2. Functions
Topics to Cover:
Function declarations and expressions
Arrow functions
Callback functions
Default parameters
Untitled 1
Exercises:
1. Write a function to calculate the factorial of a number.
2. Create a function that takes a callback and calls it after 2 seconds.
3. Write a function with default parameters for a greeting message.
Resources:
MDN: Functions
JavaScript.info: Functions
3. Objects and Arrays
Topics to Cover:
Object creation, properties, and methods
Array methods: .push() , .pop() , .map() , .filter() , .reduce() , .forEach()
Destructuring assignment
Exercises:
1. Create an object to store student details (name, age, grade). Write a function
to display these details.
2. Use .map() to create a new array of squared numbers.
3. Write a program to filter out even numbers from an array.
Resources:
MDN: Working with Objects
MDN: Array Methods
4. ES6+ Features
Topics to Cover:
Template literals
Spread/rest operators ( ... )
Destructuring
Untitled 2
Modules: import/export
Exercises:
1. Use template literals to create a string that includes variables.
2. Combine two arrays using the spread operator.
3. Use destructuring to extract specific properties from an object.
Resources:
JavaScript.info: Modern JavaScript
MDN: JavaScript ES6 Guide
5. Asynchronous JavaScript
Topics to Cover:
Callbacks
Promises ( .then() , .catch() )
async/await
Fetch API
Exercises:
1. Write a function that fetches data from a public API (e.g., JSONPlaceholder)
using Promises.
2. Convert the above function to use async/await .
3. Create a delay function using setTimeout and Promises.
Resources:
MDN: Promises
JavaScript.info: Async
6. Error Handling
Topics to Cover:
try...catch blocks
Untitled 3
Throwing custom errors
Exercises:
1. Write a function that throws an error if an invalid input is provided.
2. Wrap an API call in a try...catch block and handle errors gracefully.
Resources:
MDN: Error Handling
7. JSON and Data Handling
Topics to Cover:
JSON format
JSON.stringify() and JSON.parse()
Deep copying and cloning objects
Exercises:
1. Convert a JavaScript object into a JSON string and parse it back to an object.
2. Create a deep copy of a nested object.
Resources:
MDN: JSON
JavaScript.info: JSON
8. Basics of Node.js
Topics to Cover:
What is Node.js?
require vs import
module.exports and exports
Exercises:
1. Create a basic Node.js script that logs "Hello, Node.js!" to the console.
Untitled 4
2. Use module.exports to share a function between two files.
Resources:
Node.js Official Docs
MDN: Modules
9. DOM Manipulation (Optional but Helpful)
Topics to Cover:
Selecting elements ( getElementById , querySelector )
Event listeners
Modifying content and attributes
Exercises:
1. Create a button that changes the background color of the page on click.
2. Build a simple to-do list app with DOM manipulation.
Resources:
MDN: DOM
Documentation:
MDN JavaScript Docs
JavaScript.info
Untitled 5