Skip to content

a-mamlouk/JavaScript_basics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

JavaScript Tutorial

Welcome to the JavaScript Tutorial repository! This repository is designed to help you learn JavaScript, one of the most popular programming languages used for web development. Whether you are a beginner or looking to refresh your knowledge, this tutorial provides a comprehensive guide to get you started with JavaScript.

https://www.youtube.com/@QaAutomationAlchemist

Table of Contents

Introduction

JavaScript is a versatile, high-level, interpreted programming language that enables interactive web pages. It is a core technology of the World Wide Web, alongside HTML and CSS. This tutorial will cover the fundamentals of JavaScript, providing examples and exercises to help you practice and build your skills.

Getting Started

To get started with JavaScript, you will need a web browser and a text editor. Most modern web browsers have built-in JavaScript engines, making it easy to run JavaScript code.

  1. Web Browsers: Chrome, Firefox, Safari, or Edge.
  2. Text Editor: VS Code, Sublime Text, Atom, or any other code editor.

Basic Concepts

Syntax

JavaScript syntax is the set of rules that defines a correctly structured JavaScript program. Here are some basics:

console.log("Hello, world!");

Variables

Variables are used to store data values. Use let, const, or var to declare a variable.

let name = "John";
const age = 30;
var isStudent = true;

Data Types

JavaScript provides different data types including Number, String, Boolean, Object, Array, and more.

let number = 100;
let text = "Hello";
let isTrue = false;
let user = { name: "John", age: 30 };
let numbers = [1, 2, 3, 4, 5];

Operators

Operators are used to perform operations on variables and values.

let sum = 10 + 5;
let product = 10 * 5;
let isEqual = 10 == 5;

Control Structures

Conditional Statements

Conditional statements are used to perform different actions based on different conditions.

if (age > 18) {
  console.log("Adult");
} else {
  console.log("Minor");
}

Loops

Loops can execute a block of code a number of times.

for (let i = 0; i < 5; i++) {
  console.log(i);
}

Functions

Functions are blocks of code designed to perform a particular task.

function greet(name) {
  return "Hello, " + name;
}

console.log(greet("Alice"));

Objects and Arrays

Objects and arrays are important data structures in JavaScript.

let person = { name: "John", age: 30 };
let fruits = ["Apple", "Banana", "Cherry"];

DOM Manipulation

The Document Object Model (DOM) is a programming interface for web documents.

document.getElementById("demo").innerHTML = "Hello, DOM!";

Events

JavaScript can react to events like clicks, hover, and other user interactions.

document.getElementById("myButton").addEventListener("click", function () {
  alert("Button clicked!");
});

Asynchronous JavaScript

Asynchronous programming allows your program to start long-running tasks and still be able to respond to other events while waiting for the tasks to complete.

fetch("https://api.example.com/data")
  .then((response) => response.json())
  .then((data) => console.log(data));

Best Practices

  • Keep your code DRY (Don't Repeat Yourself)
  • Write readable and maintainable code
  • Use meaningful variable and function names
  • Comment your code
  • Follow coding standards and style guides

Resources

Contributing

Contributions are welcome! If you have suggestions or improvements, feel free to create an issue or submit a pull request.

  1. Fork the repository
  2. Create a new branch (git checkout -b feature-branch)
  3. Commit your changes (git commit -am 'Add new feature')
  4. Push to the branch (git push origin feature-branch)
  5. Create a new Pull Request

License

This project is licensed under the MIT License. See the LICENSE file for details.

Happy coding!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published