JavaScript is a versatile programming language widely used for creating dynamic and interactive web applications. Its ability to run on both the client and server sides makes it a cornerstone of modern web development.
This repository contains a collection of JavaScript projects and exercises, demonstrating fundamental concepts and applications of the language. Each folder is named with a number and a brief description of the topic it covers.
Folder | Description |
---|---|
01_website | A basic website structure to serve as a foundation for projects. |
02_variables | Demonstrates how to declare and use different types of variables. |
03_arithmetic | Examples of performing basic arithmetic operations. |
04_user_input | How to handle and process user input from a webpage. |
05_type_conversion | Examples of converting values between different data types. |
06_constants | Demonstrates the use of constants with the const keyword. |
07_counter_program | A simple web-based program that increments and decrements a counter. |
08_math | Explores various methods of the built-in Math object. |
09_random_number | A program to generate random numbers. |
10_if_statements | Basic conditional logic using if , else if , and else statements. |
11_checked | How to check the state of checkboxes and radio buttons. |
12_ternary_operator | An introduction to the shorthand ternary operator. |
13_switch | Demonstrates using switch statements for multiple conditions. |
14_string | Examples of common string properties and methods. |
15_string_slicing | How to extract a portion of a string. |
16_method_chaining | Shows how to call multiple methods on a single line. |
17_logical_operators | Examples of using && , || , and ! operators. |
18_strict_equality | Explores the difference between == and === . |
19_while_loops | How to use while loops for repetitive tasks. |
20_for_loop | Demonstrates how to use for loops for iteration. |
21_number_guessing_game | A simple game where the user tries to guess a random number. |
22_function | Introduction to creating and calling functions. |
23_variable_scope | Understanding the scope of variables in a program. |
24_temperature_conversion | A program to convert temperatures between Celsius and Fahrenheit. |
25_array | Introduction to using one-dimensional arrays. |
26_spread_operator | Demonstrates the use of the spread (... ) operator. |
27_rest_parameters | How to use rest parameters in function definitions. |
28_dice_roller | A program that simulates rolling a set of dice. |
29_random_password | A program that generates a random password. |
30_callback | An introduction to callback functions. |
31_for_each | Using the forEach array method for iteration. |
32_map | Demonstrates using the map array method. |
33_filter | How to use the filter array method. |
34_reduce | An example of using the reduce array method. |
35_function | A second look at function syntax and expressions. |
36_arrow | How to write concise arrow functions. |
37_object | Introduction to creating and using objects. |
38_this | Understanding the this keyword in different contexts. |
39_constructor | Using constructor functions to create new objects. |
40_class | Introduction to ES6 classes. |
41_static | Demonstrates the use of static properties and methods. |
42_inheritance | How to use inheritance with classes. |
43_super_keyword | Understanding the super keyword in class inheritance. |
44_getter_setter | How to use getter and setter methods in classes. |
45_destructuring | Examples of object and array destructuring. |
46_nested_objects | Working with objects that are nested within other objects. |
47_arrays_objects | Demonstrates using arrays of objects. |
48_sort | How to sort arrays. |
49_shuffle | A program to randomly shuffle the elements of an array. |
50_dates | Working with the built-in Date object. |
51_closures | An introduction to closures. |
52_setTimeout | Using setTimeout to execute code after a delay. |
53_digital_clock | A web-based digital clock. |
54_stopwatch | A simple stopwatch program. |
55_ES6_module | An introduction to ES6 modules for code organization. |
56_asynchronous | A look at asynchronous JavaScript. |
57_error_handle | How to handle errors using try...catch . |
58_calculator | A simple calculator web application. |
59_DOM | An introduction to the Document Object Model. |
60_element_selectors | How to select HTML elements using different methods. |
61_DOM_navigation | Traversing the DOM tree to access related elements. |
62_add_HTML | Dynamically adding new HTML elements to a webpage. |
63_change_HTML | How to change the content and attributes of existing HTML. |
64_mouse_event | Handling various mouse events like clicks and hovers. |
65_key_event | Handling keyboard events. |
66_hide_show_HTML | How to toggle the visibility of HTML elements. |
67_NodeList | Working with NodeList collections. |
68_classList | Manipulating an element's class list. |
69_rock_paper_scissors | A web-based Rock, Paper, Scissors game. |
70_image_slider | A simple image carousel. |
71_callback_hell | Demonstrates and explains the concept of callback hell. |
72_promise | Introduction to using Promises for asynchronous operations. |
73_async_await | How to use the async and await keywords. |
74_JSON | Working with JSON data. |
75_fetch | An introduction to the fetch API for making network requests. |
76_weather_app | A web application that fetches and displays weather data. |
-
Client-Side Scripting: JavaScript runs directly in the browser, allowing it to manipulate HTML and CSS dynamically. For example, it can update content, change styles, or respond to user interactions like clicks or keypresses.
-
Server-Side Capabilities: With environments like Node.js, JavaScript can also run on servers, enabling developers to build full-stack applications using a single language.
-
Event Handling: JavaScript can respond to browser events such as button clicks, mouse movements, or form submissions, making it essential for interactive web applications.
-
APIs and Libraries: JavaScript supports a wide range of APIs (e.g., DOM, Geolocation, Canvas) and libraries (e.g., React, Angular) to extend its functionality.
-
Asynchronous Programming: JavaScript supports asynchronous operations using Promises, async/await, and callbacks, which are crucial for tasks like fetching data from servers.
To run these projects, you can simply open the HTML files in your web browser. Most of the code will be contained within the HTML file itself or a linked JavaScript file.
-
Clone the repository to your local machine:
git clone https://github.com/your-username/your-repository-name.git
-
Navigate to a project folder, for example:
cd your-repository-name/07_counter_program
-
Open the
index.html
file in your browser.
Some projects, like 75_fetch
and 76_weather_app
, may require a simple local server due to browser security restrictions. You can use a tool like http-server
from npm:
-
Install http-server:
npm install -g http-server
-
Navigate to the project folder and run the server:
cd your-repository-name/76_weather_app http-server
-
Open the specified address in your browser (e.g.,
http://localhost:8080
).
Feel free to fork this repository and submit your own JavaScript projects or improvements via pull requests!
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.