Course Content
Introduction to JavaScript
JavaScript is one of the most popular and widely used programming languages in the world. It plays a crucial role in web development, enabling dynamic content, interactivity, and enhanced user experiences in web pages and applications. Let’s dive into what JavaScript is, its history, and how it fits into the modern web.
0/6
How to Add JavaScript?
Before diving into the basics of JavaScript, it’s essential to understand how to include JavaScript in an HTML file. There are three main ways to do this:
0/3
Different Ways to Output Data
JavaScript provides several ways to "display" or output data, allowing you to present dynamic content to users in various ways. Each method serves a different purpose and is used in different scenarios depending on the requirements. Here are the primary methods for displaying data using JavaScript:
0/4
Variables and Constants
Variables and constants in JavaScript are used to store data values. Depending on how you declare them, their value can be changed or fixed.
0/2
Data Types
JavaScript provides different types of values that can be stored in variables. These are categorized into two types: Primitives and Non-Primitives.
0/2
Conditional Statements (if, else if, else)
Conditional statements execute different actions based on different conditions.
0/2
Arrays
In JavaScript, an array is a special type of object that stores an ordered collection of values (elements). Arrays are zero-indexed, meaning the first element is accessed with index 0.
0/5
DOM Manipulation
DOM Manipulation is the process of using JavaScript to interact with and modify the HTML and CSS of a webpage. The DOM is essentially the structure of the webpage, represented as nodes, which can be elements, attributes, or pieces of text.
0/4
String Functions in JavaScript
0/1
Number Functions in Javascript
0/1
RegEx (Regular Expressions) in JavaScript
Regular expressions (regex) are patterns used to match sequences of characters in strings. They are powerful tools for searching, validating, and manipulating text.
0/3
JavaScript Modules
JavaScript modules allow developers to split code into reusable pieces that can be imported and exported across files. This makes code more maintainable, reusable, and organized.
0/4
JavaScript JSON (JavaScript Object Notation)
0/2
JavaScript Style Guide
0/1
JavaScript Best Practices
0/1
JavaScript
About Lesson
  1. Objective: Create a basic library system using classes.
  2. Instructions:
    • Create a Book class with properties: title, author, and yearPublished.
    • Create a Library class that has:
      • An array to store multiple Book instances.
      • Methods to add a book (addBook), remove a book (removeBook by title), and list all books (listBooks).
    • Add books to the library, display the library’s books, and test the add and remove functionalities.

Hint: Use inheritance if you want to create different types of books (e.g., EBook, PrintedBook), each with additional unique properties.

  1. Objective: Practice creating a class hierarchy for different types of animals.
  2. Instructions:
    • Create an Animal base class with properties like name and age, and a method makeSound() that outputs a generic message (e.g., ${name} makes a sound).
    • Create subclasses Mammal and Bird that inherit from Animal.
    • Each subclass should override the makeSound() method with a unique sound (e.g., a mammal might “growl,” and a bird might “chirp”).
    • Create instances of Mammal and Bird, and call their makeSound method to demonstrate polymorphism.

Hint: Add unique properties to each subclass, such as furColor for mammals and wingSpan for birds.

  1. Objective: Build a class hierarchy for a vehicle system.
  2. Instructions:
    1. Create a Vehicle base class with properties make, model, and year.
    1. Add a method displayInfo in Vehicle to display these details.
    1. Create Car and Motorcycle subclasses that inherit from Vehicle.
    1. Add unique properties: Car should have numDoors, and Motorcycle should have hasSidecar.
    1. Override displayInfo in each subclass to include these additional properties.
    1. Create instances of Car and Motorcycle, and display their information.

Hint: Experiment with different car and motorcycle models to see how inheritance affects each instance.

  1. Objective: Create a bank account system with specialized account types.
  2. Instructions:
    • Create an Account base class with properties accountNumber and balance, and methods deposit and withdraw.
    • Create two subclasses, SavingsAccount and CheckingAccount, that inherit from Account.
      • In SavingsAccount, add a minimumBalance property and ensure withdraw doesn’t go below this minimum.
      • In CheckingAccount, add a overdraftLimit property to allow withdrawals up to a negative limit.
    • Test with deposits and withdrawals to observe how each subclass handles balance constraints.

Hint: Use console.log to display warning messages for any violations of minimum balance or overdraft limits.

  1. Objective: Develop an employee hierarchy with unique roles.
  2. Instructions:
    • Create a base Employee class with properties name, position, and salary, and a method getDetails to display these details.
    • Create Manager and Developer subclasses.
      • Manager should have an additional property department and a method scheduleMeeting.
      • Developer should have a programmingLanguages array and a method addLanguage to add new languages.
    • Create instances of Manager and Developer, call getDetails, and use each subclass’s unique methods.

Hint: Use arrays for managing teams in Manager and programming languages in Developer.