{"id":18850578,"url":"https://github.com/manthanank/learn-javascript","last_synced_at":"2025-09-03T12:32:14.725Z","repository":{"id":65533168,"uuid":"587770857","full_name":"manthanank/learn-javascript","owner":"manthanank","description":"Complete Guide to Learn JavaScript.","archived":false,"fork":false,"pushed_at":"2024-10-15T15:20:26.000Z","size":175,"stargazers_count":15,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-25T19:44:12.628Z","etag":null,"topics":["advanced","beginner","es6","intermediate","interview","interview-questions","javascript","learn","learn-javascript","learning-javascript","nodejs","package","snippets"],"latest_commit_sha":null,"homepage":"https://manthanank.github.io/learn-javascript/","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/manthanank.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-11T14:49:17.000Z","updated_at":"2024-11-16T09:44:15.000Z","dependencies_parsed_at":"2024-02-04T14:30:02.742Z","dependency_job_id":"233bee6e-7824-418a-a7ca-f1d421438bbc","html_url":"https://github.com/manthanank/learn-javascript","commit_stats":{"total_commits":53,"total_committers":2,"mean_commits":26.5,"dds":"0.15094339622641506","last_synced_commit":"27515469c2fb4e487f9802f0bf576e9f23dd54d6"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manthanank%2Flearn-javascript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manthanank%2Flearn-javascript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manthanank%2Flearn-javascript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manthanank%2Flearn-javascript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/manthanank","download_url":"https://codeload.github.com/manthanank/learn-javascript/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231882053,"owners_count":18440323,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["advanced","beginner","es6","intermediate","interview","interview-questions","javascript","learn","learn-javascript","learning-javascript","nodejs","package","snippets"],"created_at":"2024-11-08T03:29:57.718Z","updated_at":"2025-09-03T12:32:14.647Z","avatar_url":"https://github.com/manthanank.png","language":"Dockerfile","readme":"# Learn JavaScript\n\nThis repository contains a list of JavaScript concepts, functions, methods, and other important topics that are essential for every JavaScript developer to learn. It is a comprehensive guide that covers all the basic and advanced concepts of JavaScript.\n\n![npm](https://img.shields.io/npm/dw/learn-javascript)\n![npm](https://img.shields.io/npm/dm/learn-javascript)\n![npm](https://img.shields.io/npm/dy/learn-javascript)\n![npm](https://img.shields.io/npm/dt/learn-javascript)\n![GitHub repo size](https://img.shields.io/github/repo-size/manthanank/learn-javascript)\n\n![GitHub](https://img.shields.io/github/license/manthanank/learn-javascript)\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Add JavaScript](#add-javascript)\n- [Output JavaScript](#outputing-javascript)\n- [Single Line Comments](#single-line-comments)\n- [Multi Line Comments](#multi-line-comments)\n- [Variables](#variables)\n  - [Declare Variables](#declare-variables)\n- [Data Types](#data-types)\n  - [Primitive Data Types](#1-primitive-data-types)\n  - [Non Primitive Data Types](#2-non-primitive-data-types)\n- [Operators](#operators)\n  - [Arithmetic Operators](#arithmetic-operators)\n  - [Logical Operators](#logical-operators)\n  - [Comparison Operators](#comparison-operators)\n  - [Bitwise Operators](#bitwise-operators)\n  - [Type operators](#type-operators)\n  - [Assignment Operators](#assignment-operators)\n  - [Conditional (Ternary) Operators](#conditional-ternary-operator)\n  - [Nullish Coalescing Operator(??)](#nullish-coalescing-operator)\n  - [Optional Chaining Operator(?.)](#optional-chaining-operator)\n  - [delete Operator](#delete-operator)\n  - [Spread (...) Operator](#spread--operator)\n- [Arrays](#arrays)\n  - [Array Methods](#array-methods)\n- [Strings](#strings)\n  - [String Methods](#strings-methods)\n- [Loops](#loops)\n  - [for Loop](#for-loop)\n  - [while Loop](#while-loop)\n  - [do while Loop](#do-while-loop)\n  - [for in Loop](#for-in-loop)\n  - [for of Loop](#for-of-loop)\n- [Conditional Statements](#conditional-statements)\n  - [if statement](#if-statement)\n  - [if else statement](#if-else-statement)\n  - [if else else if statement](#if-else-else-if-statement)\n  - [switch statement](#switch-statement)\n- [Functions](#functions)\n  - [Named Function](#named-function)\n  - [Anonymous Function](#anonymous-function)\n  - [Arrow Functions](#arrow-function)\n  - [Immediately Invoked Function Expression (IIFE)](#iife)\n  - [Higher Order Function](#higher-order-functions)\n  - [Function Declaration](#function-declaration)\n  - [Function Expression](#function-expression)\n  - [Function Constructor](#function-constructor)\n- [Scope](#scope)\n  - [Block Scope](#block-scope)\n  - [Function Scope](#function-scope)\n  - [Global Scope](#global-scope)\n- [Hoisting](#hoisting)\n- [Currying](#currying)\n- [Dates](#dates)\n  - [Date Methods](#date-methods)\n- [Date Get Methods](#date-get-methods)\n- [Date Set Methods](#date-set-methods)\n- [Type Conversion](#type-conversion)\n  - [Convert string to numbers](#convert-string-to-numbers)\n  - [Convert number to a string](#convert-number-to-a-string)\n  - [Convert dates to numbers](#convert-dates-to-numbers)\n  - [Convert boolean to number](#convert-boolean-to-number)\n  - [Convert boolean to string](#convert-boolean-to-string)\n- [Typeof](#typeof)\n- [Math](#math)\n  - [Math Property](#math-property)\n  - [Math Methods](#math-methods)\n- [Sets](#sets)\n  - [Set Methods](#set-methods)\n- [Map](#map)\n  - [Map Methods](#map-methods)\n- [Recursion](#recursion)\n- [Async](#async)\n- [DOM](#dom)\n- [Browser BOM](#browser-bom)\n- [JSON](#json)\n- [Web API](#web-api)\n- [Ajax](#ajax)\n- [jQuery](#jquery)\n- [Graphics](#graphics)\n- [Best Practices](#best-practices)\n- [Common Mistakes](#common-mistakes)\n- [Performace](#performance)\n- [ES6 Featues](#es6-features)\n- [ES5 Features](#es5-features)\n- [Snippets](#snippets)\n- [Short Hands](#short-hands)\n- [Interview Questions](#interview-questions)\n- [List of GitHub Repositories to learn JavaScript](#list-of-github-repositories-to-learn-javascript)\n- [List of Websites to learn JavaScript](#list-of-websites-to-learn-javascript)\n- [List of Books to learn JavaScript](#list-of-books-to-learn-javascript)\n- [List of YouTube Channels to learn JavaScript](#list-of-youtube-channels-to-learn-javascript)\n- [List of Udemy Courses to learn JavaScript](#list-of-udemy-courses-to-learn-javascript)\n- [List of Games to learn JavaScript by playing](#list-of-games-to-learn-javascript-by-playing)\n- [List of Blogs Sites to learn JavaScript](#list-of-blogs-sites-to-learn-javascript)\n- [List of JavaScript Online Editors/Compilers](#list-of-javascript-online-editorscompilers)\n- [List of Twitter Users](#list-of-twitter-users)\n- [List of LinkedIn Users](#list-of-linkedin-users)\n\n## Introduction\n\n**JavaScript** is a scripting language. It is object-based, lightweight, cross-platform translated language. It is widely used for client-side validation.\n\n## Add JavaScript\n\nThere are three ways to add JavaScript to a web page:\n\n1. **Inline JavaScript** - It is used to add JavaScript directly to the HTML document. It is added inside the `\u003cscript\u003e` tag in the HTML document.\n\n2. **Internal JavaScript** - It is used to add JavaScript to the HTML document. It is added inside the `\u003cscript\u003e` tag in the `\u003chead\u003e` or `\u003cbody\u003e` section of the HTML document.\n\n3. **External JavaScript** - It is used to add JavaScript to the HTML document. It is added in a separate file with a `.js` extension and linked to the HTML document using the `\u003cscript\u003e` tag.\n\n**JavaScript in `\u003chead\u003e`** -\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n\u003cscript\u003e\n    //code\n\u003c/script\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\u003ch2\u003eHeading\u003c/h2\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n**JavaScript in `\u003cbody\u003e`**\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003cbody\u003e\n\n\u003ch2\u003eHeading\u003c/h2\u003e\n\n\u003cscript\u003e\n    //code\n\u003c/script\u003e\n\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n**External JavaScript** -\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003cbody\u003e\n\n\u003ch2\u003eHeading\u003c/h2\u003e\n\n\u003cscript src=\"myScript.js\"\u003e\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Outputing JavaScript\n\n### JavaScript can \"display\" data in different ways\n\n**1. Writing into an HTML element, using `innerHTML`**\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003cbody\u003e\n\n\u003ch1\u003eMy First Web Page\u003c/h1\u003e\n\u003cp\u003eMy First Paragraph\u003c/p\u003e\n\n\u003cp id=\"demo\"\u003e\u003c/p\u003e\n\n\u003cscript\u003e\ndocument.getElementById(\"demo\").innerHTML = 5 + 6;\n\u003c/script\u003e\n\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n**2. Writing into an HTML element, using `document.write()`**\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003cbody\u003e\n\n\u003ch1\u003eMy First Web Page\u003c/h1\u003e\n\u003cp\u003eMy first paragraph.\u003c/p\u003e\n\n\u003cscript\u003e\ndocument.write(5 + 6);\n\u003c/script\u003e\n\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n**3. Writing into an alert box, using `window.alert()`**\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003cbody\u003e\n\n\u003ch1\u003eMy First Web Page\u003c/h1\u003e\n\u003cp\u003eMy first paragraph.\u003c/p\u003e\n\n\u003cscript\u003e\nwindow.alert(5 + 6);\n\u003c/script\u003e\n\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n**4. Writing into the browser console, using `console.log()`**\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003cbody\u003e\n\n\u003cscript\u003e\nconsole.log(5 + 6);\n\u003c/script\u003e\n\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Single Line Comments\n\nSingle line comments start with `//`\n\n```jsx\n// comments\n```\n\n## Multi-line Comments\n\nMulti-line comments start with `/*` and end with `*/`.\n\n```jsx\n/* Hey!\nHello, How are you?\n*/ \n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Variables\n\nVariables are containers for storing data values. In JavaScript, variables are declared using the `var`, `let`, or `const` keyword.\n\n### Declare Variables\n\nThere are three ways to declare variables in JavaScript:\n\n**1. var** - It is used to declare a variable. It is function-scoped.\n\n```jsx\nvar a = 1; // Declare a variable x with the value 1 (function-level scope).\n```\n\n**2. let** - It is used to declare a variable. It is block-scoped.\n\n```jsx\nlet b = 1; // Declare a variable y with the value 10 (block-level scope).\n```\n\n**3. const** - It is used to declare a read-only variable. It is block-scoped.\n\n```jsx\nconst c = 1; // Declare a read-only variable z with the value 15 (block-level scope).\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Data Types\n\nData types are used to define the type of data that a variable can store. JavaScript is a loosely typed language, which means that you do not have to declare the data type of a variable when you declare it.\n\nThere are two types of data types in JavaScript:\n\n- **Primitive Data Types**\n- **Non-Primitive Data Types**\n\n### 1. Primitive Data Types\n\n**Primitive data types** are the most basic data types in JavaScript. They are immutable (cannot be changed) and are copied by value.\n\n**Primitive data types** include:\n\n- **numbers**\n- **strings**\n- **booleans**\n- **null**\n- **undefined**\n- **symbol**\n\n**numbers** - numbers can be written with or without decimals.\n\n```javascript\nlet number = 10;\n```\n\n**strings** - strings are text. They are written inside double or single quotes.\n\n```javascript\nlet name = \"Manthan\";\n```\n\n**booleans** - booleans can only have two values: true or false.\n\n```javascript\nlet value1 = true;\nlet value2 = false;\n```\n\n**null** - null is an empty value.\n\n```javascript\nlet value = null;\n```\n\n**undefined** - undefined means a variable has been declared but has not yet been assigned a value.\n\n```javascript\nlet name;\n```\n\n**symbol** - symbols are unique and immutable values.\n\n```javascript\nlet a = Symbol();\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### 2. Non Primitive Data Types\n\n**Non-primitive data types** are complex data types that are mutable (can be changed) and are copied by reference.\n\n**Non-primitive data types** include:\n\n- **objects**\n- **arrays**\n- **functions**\n- **regexp**\n\n**functions** - functions are objects that can be invoked.\n\n```javascript\nfunction greet() {\n  return \"Hello!\";\n}\n```\n\n**object** - objects are used to store collections of data and more complex entities.\n\n```javascript\nlet name = {firstName:\"Manthan\", lastName:\"Ank\"};\n```\n\n**arrays** - arrays are used to store multiple values in a single variable.\n\n```javascript\nlet array = [\"value1\", \"value2\"];\n```\n\n**regexp** - regular expressions are used to perform pattern-matching in strings.\n\n```javascript\nlet pattern = /w3schools/i;\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Operators\n\nOperators are used to perform operations on variables and values.\n\nThere are different types of operators in JavaScript:\n\n- **Arithmetic Operators**\n- **Logical Operators**\n- **Comparison Operators**\n- **Bitwise Operators**\n- **Type Operators**\n- **Assignment Operators**\n- **Conditional (Ternary) Operator**\n- **Nullish Coalescing Operator(??)**\n- **Optional Chaining Operator(?.)**\n- **delete Operator**\n- **Spread (...) Operator**\n\n### Arithmetic Operators\n\n| Operator | Description |\n| :-----------: | :-----------: |\n| + | Addition |\n| - | Subtraction |\n| * | Multiplication |\n| ** | Exponentiation (ES2016) |\n| / | Division |\n| % | Modulus (Division Remainder) |\n| ++ | Increment |\n| -- | Decrement |\n\nExamples\n\n```javascript\nlet x = 5;\nlet y = 2;\n\nconsole.log(x + y); // Output: 7\nconsole.log(x - y); // Output: 3\nconsole.log(x * y); // Output: 10\nconsole.log(x / y); // Output: 2.5\nconsole.log(x % y); // Output: 1\n\nx++;\nconsole.log(x); // Output: 6\n\ny--;\nconsole.log(y); // Output: 1\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### Logical Operators\n\n| Operator | Description |\n| :-----------: | :-----------: |\n| \u0026\u0026 | logical and |\n| ll | logical or |\n| ! | logical not |\n\nExamples\n\n```javascript\nlet x = true;\nlet y = false;\n\nconsole.log(x \u0026\u0026 y); // Output: false\nconsole.log(x || y); // Output: true\nconsole.log(!x); // Output: false\nconsole.log(!y); // Output: true\n```\n\n### Comparison Operators\n\n| Operator | Description |\n| :-----------: | :-----------: |\n| == | equal to |\n| === | equal value and equal type |\n| != | not equal |\n| !== | not equal value or not equal type |\n| \u003e | greater than |\n| \u003c | less than |\n| \u003e= | greater than or equal to |\n| \u003c= | less than or equal to |\n| ?| ternary operator |\n\nExamples\n\n```javascript |\nlet x = 5;\nlet y = 10;\n\nconsole.log(x == y); // Output: false\nconsole.log(x === y); // Output: false\nconsole.log(x != y); // Output: true\nconsole.log(x !== y); // Output: true\nconsole.log(x \u003e y); // Output: false\nconsole.log(x \u003c y); // Output: true\nconsole.log(x \u003e= y); // Output: false\nconsole.log(x \u003c= y); // Output: true\nconsole.log(x ? y : x); // Output: 10\nconsole.log(x ? x : y); // Output: 5\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### Bitwise Operators\n\n| Operator | Description |\n| :-----------: | :-----------: |\n| \u0026 | AND |\n| l | OR |\n| ~ | NOT |\n| ^| XOR |\n| \u003c\u003c | Left shift |\n| \u003e\u003e | Right shift |\n| \u003e\u003e\u003e | Unsigned right |\n\nExamples\n\n```javascript\nlet x = 5; // Binary representation: 101\nlet y = 3; // Binary representation: 011\n\nconsole.log(x \u0026 y); // Output: 1 (binary: 001)\nconsole.log(x | y); // Output: 7 (binary: 111)\nconsole.log(x ^ y); // Output: 6 (binary: 110)\nconsole.log(~x); // Output: -6 (binary: 11111111111111111111111111111010)\nconsole.log(x \u003c\u003c 1); // Output: 10 (binary: 1010)\nconsole.log(x \u003e\u003e 1); // Output: 2 (binary: 10)\nconsole.log(x \u003e\u003e\u003e 1); // Output: 2 (binary: 10)\n```\n\n### Type Operators\n\n| Operator | Description |\n| :-----------: | :-----------: |\n| typeof | Returns the type of a variable |\n| instanceof | Returns true if an object is an instance of an object type |\n\nExamples\n\n```javascript\nconsole.log(typeof 5); // Output: \"number\"\nconsole.log(typeof 'hello'); // Output: \"string\"\nconsole.log(typeof true); // Output: \"boolean\"\nconsole.log(typeof undefined); // Output: \"undefined\"\nconsole.log(typeof null); // Output: \"object\" (this is a bug in JavaScript)\nconsole.log(typeof {}); // Output: \"object\"\nconsole.log(typeof []); // Output: \"object\"\nconsole.log(typeof function() {}); // Output: \"function\"\n\nlet cars = ['BMW', 'Volvo', 'Mini'];\n\nconsole.log(cars instanceof Array); // Output: true\nconsole.log(cars instanceof Object); // Output: true\nconsole.log(cars instanceof String); // Output: false\nconsole.log(cars instanceof Number); // Output: false\nconsole.log(cars instanceof Function); // Output: false\nconsole.log(cars instanceof RegExp); // Output: false\nconsole.log(cars instanceof Date); // Output: false\nconsole.log(cars instanceof Symbol); // Output: false\nconsole.log(cars instanceof Boolean); // Output: false\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### Assignment Operators\n\n| Operator | Description |\n| :-----------: | :-----------: |\n| = | x = y |\n| += | x += y |\n| -= | x -= y |\n| *= | x *= y |\n| /= | x /= y |\n| %= | x %= y |\n| **= | x **= y |\n| : | x : 45 |\n\n```javascript\nlet x = 5;\nlet y = 10;\n\nx += y; // x = x + y\nconsole.log(x); // Output: 15\n\nx -= y; // x = x - y\nconsole.log(x); // Output: 5\n\nx *= y; // x = x * y\nconsole.log(x); // Output: 50\n\nx /= y; // x = x / y\nconsole.log(x); // Output: 5\n\nx %= y; // x = x % y\nconsole.log(x); // Output: 5\n\nx **= y; // x = x ** y\nconsole.log(x); // Output: 9765625\n\nx = y; // x = y\nconsole.log(x); // Output: 10\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### Conditional (Ternary) Operator\n\nThe conditional (ternary) operator is the only JavaScript operator that takes three operands: a condition followed by a question mark (?), then an expression to execute if the condition is truthy followed by a colon (:), and finally the expression to execute if the condition is falsy.\n\nSyntax\n\n```javascript\n(condition) ? x : y\n```\n\n```javascript\nlet x = 10;\nlet y = 5;\n\nlet result = (x \u003e y) ? \"x is greater than y\" : \"x is less than y\";\n\nconsole.log(result); // Output: \"x is greater than y\"\n```\n\n### Nullish Coalescing Operator(??)\n\nThe nullish coalescing operator (??) is a new operator in JavaScript that returns the right-hand operand when the left-hand operand is null or undefined.\n\nExample\n\n```javascript\nlet x = null;\nlet y = undefined;\nlet z = 'Hello';\n\nconsole.log(x ?? 'Default Value'); // Output: \"Default Value\"\nconsole.log(y ?? 'Default Value'); // Output: \"Default Value\"\nconsole.log(z ?? 'Default Value'); // Output: \"Hello\"\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### Optional Chaining Operator(?.)\n\nThe optional chaining operator (?.) is a new operator in JavaScript that allows you to access properties of an object without having to check if the object or its properties are null or undefined.\n\nExample\n\n```javascript\nlet person = {\n  name: 'John',\n  age: 30,\n  address: {\n    street: '123 Main St',\n    city: 'New York',\n    state: 'NY'\n  }\n};\n\nconsole.log(person.address?.city); // Output: \"New York\"\nconsole.log(person.address?.zipCode); // Output: undefined\n```\n\n### delete Operator\n\nThe delete operator is used to delete a property from an object.\n\nExample\n\n```javascript\nconst person = {\n  firstName:\"Manthan\",\n  lastName:\"Ank\",\n  age:25,\n  eyeColor:\"black\"\n};\n\ndelete person.age;\n\nconsole.log(person); // Output: {firstName: \"Manthan\", lastName: \"Ank\", eyeColor: \"black\"}\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### Spread (...) Operator\n\nThe spread operator is a new addition to the JavaScript language in ES6. It is denoted by three dots (...). It is used to expand an array or object into individual elements.\n\nExample\n\n```javascript\n// Array literal\nlet numbers = [1, 2, 3];\nlet newNumbers = [...numbers, 4, 5, 6];\nconsole.log(newNumbers); // Output: [1, 2, 3, 4, 5, 6]\n\n// Object literal\nlet person = {name: 'John', age: 30};\nlet newPerson = {...person, city: 'New York', country: 'USA'};\nconsole.log(newPerson); // Output: {name: \"John\", age: 30, city: \"New York\", country: \"USA\"}\n\n// Function call\nfunction sum(a, b, c) {\n  return a + b + c;\n}\nlet numbers = [1, 2, 3];\nconsole.log(sum(...numbers)); // Output: 6\n\n// Copy an array\nlet numbers = [1, 2, 3];\nlet newNumbers = [...numbers];\nconsole.log(newNumbers); // Output: [1, 2, 3]\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Boolean\n\nJavaScript booleans can have one of two values: true or false.\n\n```javascript\nlet value = true;\n```\n\n### Boolean Methods and Properties\n\nThe following are some of the most commonly used boolean methods and properties in JavaScript:\n\n**constructor** - Returns the function that created JavaScript's Boolean prototype\n\n```javascript\nlet value = true;\n\nconsole.log(value.constructor); // Output: ƒ Boolean() { [native code] }\n```\n\n**prototype** - Allows you to add properties and methods to the Boolean prototype\n\n```javascript\nBoolean.prototype.age = 25;\n\nlet value = true;\n\nconsole.log(value.age); // Output: 25\n```\n\n**toString()** - Converts a boolean value to a string, and returns the result\n\n```javascript\nlet value = true;\n\nconsole.log(value.toString()); // Output: \"true\"\n```\n\n**valueOf()** - Returns the primitive value of a boolean\n\n```javascript\nlet value = true;\n\nconsole.log(value.valueOf()); // Output: true\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Object\n\nObjects are used to store key/value (name/value) collections.\n\n```javascript\nconst person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n```\n\n### Object Methods \u0026 Properties\n\nThe following are some of the most commonly used object methods and properties in JavaScript:\n\n**constructor** - Returns the function that created an object's prototype\n\n```javascript\nlet person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nconsole.log(person.constructor); // Output: ƒ Object() { [native code] }\n```\n\n**keys()** - Returns an Array Iterator object with the keys of an object\n\n```javascript\nconst person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nlet keys = Object.keys(person);\nconsole.log(keys); // Output: [\"firstName\", \"lastName\"]\n```\n\n**prototype** - Let you to add properties and methods to JavaScript objects\n\n```javascript\nlet person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nObject.prototype.age = 25;\n\nconsole.log(person.age); // Output: 25\n```\n\n**toString()** - Converts an object to a string and returns the result\n\n```javascript\nlet person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nconsole.log(person.toString()); // Output: \"[object Object]\"\n```\n\n**valueOf()** - Returns the primitive value of an object\n\n```javascript\nlet person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nconsole.log(person.valueOf()); // Output: {firstName: \"Manthan\", lastName: \"Ank\"}\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Arrays\n\nArrays are used to store multiple values in a single variable.\n\n```javascript\nconst letters = ['a', 'b', 'c'];\n```\n\n### Array Methods\n\nThe following are some of the most commonly used array methods in JavaScript:\n\n- **at()**\n- **concat()**\n- **constructor**\n- **copyWithin()**\n- **entries()**\n- **every()**\n- **fill()**\n- **filter()**\n- **find()**\n- **findIndex()**\n- **findLast()**\n- **findLastIndex()**\n- **flat()**\n- **flatMap()**\n- **forEach()**\n- **from()**\n- **includes()**\n- **indexOf()**\n- **isArray()**\n- **join()**\n- **keys()**\n- **lastIndexOf()**\n- **length**\n- **map()**\n- **pop()**\n- **prototype**\n- **push()**\n- **reduce()**\n- **reduceRight()**\n- **reverse()**\n- **shift()**\n- **slice()**\n- **some()**\n- **sort()**\n- **splice()**\n- **toLocaleString()**\n- **toReversed()**\n- **toSorted()**\n- **toSpliced()**\n- **toString()**\n- **unshift()**\n- **valueOf()**\n- **values()**\n- **with()**\n\n[Back to Top⤴️](#table-of-contents)\n\n**at()** - Returns the element at a specified index in an array\n\n```javascript\nlet array = ['a', 'b', 'c'];\n\nconsole.log(array.at(1)); // Output: \"b\"\n```\n\n**concat()** - Joins arrays and returns an array with the joined arrays.\n\n```javascript\nlet array1 = ['a', 'b', 'c'];\nlet array2 = ['d', 'e', 'f'];\n\nlet mergedArray = array1.concat(array2);\nconsole.log(mergedArray); // mergedArray is ['a', 'b', 'c', 'd', 'e', 'f']\n```\n\n**constructor** - Returns the function that created the Array object's prototype\n\n```javascript\nlet array = ['a', 'b', 'c'];\n\nconsole.log(array.constructor); // Output: ƒ Array() { [native code] }\n```\n\n**copyWithin()** - Copies array elements within the array, to and from specified positions\n\n```javascript\nlet array = ['a', 'b', 'c', 'd', 'e', 'f'];\n\narray.copyWithin(2, 0);\nconsole.log(array); // Output: [\"a\", \"b\", \"a\", \"b\", \"c\", \"d\"]\n\narray.copyWithin(4, 0, 2);\nconsole.log(array); // Output: [\"a\", \"b\", \"a\", \"b\", \"a\", \"b\"]\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**entries()** - Returns a key/value pair Array Iteration Object\n\n```javascript\nlet array = ['a', 'b', 'c'];\n\nlet iterator = array.entries();\n\nconsole.log(iterator.next().value); // Output: [0, \"a\"]\nconsole.log(iterator.next().value); // Output: [1, \"b\"]\nconsole.log(iterator.next().value); // Output: [2, \"c\"]\n```\n\n**every()** - Checks if every element in an array pass a test\n\n```javascript\nlet array = [1, 2, 3, 4, 5];\n\nlet result = array.every(value =\u003e value \u003e 0);\n\nconsole.log(result); // Output: true\n```\n\n**fill()** - Fill the elements in an array with a static value\n\n```javascript\nlet array = ['a', 'b', 'c', 'd', 'e', 'f'];\n\narray.fill('x', 2, 4);\n\nconsole.log(array); // Output: [\"a\", \"b\", \"x\", \"x\", \"e\", \"f\"]\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**filter()** - Creates a new array with every element in an array that pass a test\n\n```javascript\nlet array = [1, 2, 3, 4, 5];\n\nlet newArray = array.filter(value =\u003e value \u003e 3);\n\nconsole.log(array); // Output: [1, 2, 3, 4, 5]\nconsole.log(newArray); // Output: [4, 5]\n```\n\n**find()** - Returns the value of the first element in an array that pass a test\n\n```javascript\nlet array = [1, 2, 3, 4, 5];\n\nlet value = array.find(value =\u003e value \u003e 3);\n\nconsole.log(array); // Output: [1, 2, 3, 4, 5]\nconsole.log(value); // Output: 4\n```\n\n**findIndex()** - Returns the index of the first element in an array that pass a test\n\n```javascript\nlet array = [1, 2, 3, 4, 5];\n\nlet index = array.findIndex(value =\u003e value \u003e 3);\n\nconsole.log(array); // Output: [1, 2, 3, 4, 5]\nconsole.log(index); // Output: 3\n```\n\n**findLast()** - Returns the value of the last element in an array that pass a test\n\n```javascript\nlet array = [1, 2, 3, 4, 5];\n\nlet value = array.findLast(value =\u003e value \u003e 3);\n\nconsole.log(array); // Output: [1, 2, 3, 4, 5]\nconsole.log(value); // Output: 5\n```\n\n**findLastIndex()** - Returns the index of the last element in an array that pass a test\n\n```javascript\nlet array = [1, 2, 3, 4, 5];\n\nlet index = array.findLastIndex(value =\u003e value \u003e 3);\n\nconsole.log(array); // Output: [1, 2, 3, 4, 5]\nconsole.log(index); // Output: 4\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**flat()** - Flattens an array up to a specified depth\n\n```javascript\nlet array = [1, 2, [3, 4, [5, 6]]];\n\nlet newArray = array.flat(2);\n\nconsole.log(array); // Output: [1, 2, [3, 4, [5, 6]]]\nconsole.log(newArray); // Output: [1, 2, 3, 4, 5, 6]\n```\n\n**flatMap()** - Maps each element using a mapping function, then flattens the result into a new array\n\n```javascript\nlet array = [1, 2, 3, 4, 5];\n\nlet newArray = array.flatMap(value =\u003e [value * 2]);\n\nconsole.log(array); // Output: [1, 2, 3, 4, 5]\nconsole.log(newArray); // Output: [2, 4, 6, 8, 10]\n```\n\n**forEach()** - Calls a function for each array element\n\n```javascript\nlet array = [1, 2, 3, 4, 5];\n\narray.forEach(value =\u003e {\n  console.log(value);\n});\n\n// Output: 1\n// Output: 2\n// Output: 3\n// Output: 4\n// Output: 5\n```\n\n**from()** - Creates an array from an object\n\n```javascript\nlet array = 'hello';\n\nlet newArray = Array.from(array);\n\nconsole.log(array); // Output: \"hello\"\nconsole.log(newArray); // Output: [\"h\", \"e\", \"l\", \"l\", \"o\"]\n```\n\n**includes()** - Check if an array contains the specified element\n\n```javascript\nlet array = [1, 2, 3, 4, 5];\n\nlet result = array.includes(3);\n\nconsole.log(array); // Output: [1, 2, 3, 4, 5]\n\nconsole.log(result); // Output: true\nconsole.log(array.includes(6)); // Output: false\n```\n\n**indexOf()** - Search the array for an element and returns its position\n\n```javascript\nlet array = [1, 2, 3, 4, 5];\n\nlet index = array.indexOf(3);\n\nconsole.log(array); // Output: [1, 2, 3, 4, 5]\n\nconsole.log(index); // Output: 2\nconsole.log(array.indexOf(6)); // Output: -1\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**isArray()** - Checks whether an object is an array\n\n```javascript\nlet array = [1, 2, 3, 4, 5];\n\nlet result = Array.isArray(array);\n\nconsole.log(array); // Output: [1, 2, 3, 4, 5]\n\nconsole.log(result); // Output: true\nconsole.log(Array.isArray('hello')); // Output: false\n```\n\n**join()** - Joins all elements of an array into a string\n\n```javascript\nlet array = ['a', 'b', 'c'];\n\nlet result = array.join();\n\nconsole.log(array); // Output: [\"a\", \"b\", \"c\"]\nconsole.log(result); // Output: \"a,b,c\"\n```\n\n**keys()** - Returns a Array Iteration Object, containing the keys of the original array\n\n```javascript\nlet array = ['a', 'b', 'c'];\n\nlet iterator = array.keys();\n\nconsole.log(array); // Output: [\"a\", \"b\", \"c\"]\nconsole.log(iterator.next().value); // Output: 0\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**lastIndexOf()** - Search the array for an element, starting at the end, and returns its position\n\n```javascript\nlet array = [1, 2, 3, 4, 5, 3];\n\nlet index = array.lastIndexOf(3);\n\nconsole.log(array); // Output: [1, 2, 3, 4, 5, 3]\nconsole.log(index); // Output: 5\n```\n\n**length** - Sets or returns the number of elements in an array\n\n```javascript\nlet array = ['a', 'b', 'c'];\n\nconsole.log(array); // Output: [\"a\", \"b\", \"c\"]\nconsole.log(array.length); // Output: 3\n```\n\n**map()** - Creates a new array with the result of calling a function for each array element\n\n```javascript\nlet array = [1, 2, 3, 4, 5];\n\nlet newArray = array.map(value =\u003e value * 2);\n\nconsole.log(array); // Output: [1, 2, 3, 4, 5]\nconsole.log(newArray); // Output: [2, 4, 6, 8, 10]\n```\n\n**pop()** - Removes the last element of an array, and returns that element\n\n```javascript\nlet array = ['a', 'b', 'c'];\n\nlet element = array.pop();\n\nconsole.log(array); // Output: [\"a\", \"b\"]\nconsole.log(element); // Output: \"c\"\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**prototype** - Allows you to add properties and methods to an Array object\n\n```javascript\nlet array = ['a', 'b', 'c'];\n\nArray.prototype.age = 25;\n\nconsole.log(array); // Output: [\"a\", \"b\", \"c\"]\nconsole.log(array.age); // Output: 25\n```\n\n**push()** - Adds new elements to the end of an array, and returns the new length\n\n```javascript\nlet array = ['a', 'b', 'c'];\n\nlet length = array.push('d', 'e');\n\nconsole.log(array); // Output: [\"a\", \"b\", \"c\", \"d\", \"e\"]\nconsole.log(length); // Output: 4\n```\n\n**reduce()** - Reduce the values of an array to a single value (going left-to-right)\n\n```javascript\nlet array = [1, 2, 3, 4, 5];\n\nlet total = array.reduce((accumulator, value) =\u003e accumulator + value, 0);\n\nconsole.log(array); // Output: [1, 2, 3, 4, 5]\nconsole.log(total); // Output: 15\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**reduceRight()** - Reduce the values of an array to a single value (going right-to-left)\n\n```javascript\nlet array = [1, 2, 3, 4, 5];\n\nlet total = array.reduceRight((accumulator, value) =\u003e accumulator + value, 0);\n\nconsole.log(array); // Output: [1, 2, 3, 4, 5]\nconsole.log(total); // Output: 15\n```\n\n**reverse()** - Reverses the order of the elements in an array\n\n```javascript\nlet array = ['a', 'b', 'c'];\n\narray.reverse();\n\nconsole.log(array); // Output: [\"c\", \"b\", \"a\"]\n```\n\n**shift()** - Removes the first element of an array, and returns that element\n\n```javascript\nlet array = ['a', 'b', 'c'];\n\nlet element = array.shift();\n\nconsole.log(array); // Output: [\"b\", \"c\"]\nconsole.log(element); // Output: \"a\"\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**slice()** - Selects a part of an array, and returns the new array\n\n```javascript\nlet array = ['a', 'b', 'c', 'd', 'e', 'f'];\n\nlet newArray = array.slice(2, 4);\n\nconsole.log(array); // Output: [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"]\nconsole.log(newArray); // Output: [\"c\", \"d\"]\n```\n\n**some()** - Checks if any of the elements in an array pass a test\n\n```javascript\nlet array = [1, 2, 3, 4, 5];\n\nlet result = array.some(value =\u003e value \u003e 3);\n\nconsole.log(array); // Output: [1, 2, 3, 4, 5]\nconsole.log(result); // Output: true\n```\n\n**sort()** - Sorts the elements of an array\n\n```javascript\nlet array = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5];\n\narray.sort();\n\nconsole.log(array); // Output: [1, 1, 2, 3, 3, 4, 5, 5, 5, 6, 9]\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**splice()** - Adds/Removes elements from an array\n\n```javascript\nlet array = ['a', 'b', 'c', 'd', 'e', 'f'];\n\narray.splice(2, 0, 'x', 'y');\n\nconsole.log(array); // Output: [\"a\", \"b\", \"x\", \"y\", \"c\", \"d\", \"e\", \"f\"]\n```\n\n**toLocaleString()** - Converts an array to a string, using locale-specific settings\n\n```javascript\nlet array = ['a', 'b', 'c'];\n\nconsole.log(array.toLocaleString()); // Output: \"a,b,c\"\n```\n\n**toReversed()** - Reverses the elements of an array\n\n```javascript\nlet array = ['a', 'b', 'c'];\n\nlet reversedArray = array.toReversed();\n\nconsole.log(array); // Output: [\"a\", \"b\", \"c\"]\nconsole.log(reversedArray); // Output: [\"c\", \"b\", \"a\"]\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**toSorted()** - Sorts the elements of an array\n\n```javascript\nlet array = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5];\n\nlet sortedArray = array.toSorted();\n\nconsole.log(array); // Output: [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]\nconsole.log(sortedArray); // Output: [1, 1, 2, 3, 3, 4, 5, 5, 5, 6, 9]\n```\n\n**toSpliced()** - Adds/Removes elements from an array\n\n```javascript\nlet array = ['a', 'b', 'c', 'd', 'e', 'f'];\n\nlet splicedArray = array.toSpliced(2, 0, 'x', 'y');\n\nconsole.log(array); // Output: [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"]\nconsole.log(splicedArray); // Output: [\"a\", \"b\", \"x\", \"y\", \"c\", \"d\", \"e\", \"f\"]\n```\n\n**toString()** - Converts an array to a string, and returns the result\n\n```javascript\nlet array = ['a', 'b', 'c'];\n\nconsole.log(array.toString()); // Output: \"a,b,c\"\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**unshift()** - Adds new elements to the beginning of an array, and returns the new length\n\n```javascript\nlet array = ['a', 'b', 'c'];\n\nlet length = array.unshift('x', 'y');\n\nconsole.log(array); // Output: [\"x\", \"y\", \"a\", \"b\", \"c\"]\n```\n\n**valueOf()** - Returns the primitive value of an array\n\n```javascript\nlet array = ['a', 'b', 'c'];\n\nconsole.log(array.valueOf()); // Output: [\"a\", \"b\", \"c\"]\n```\n\n**values()** - Returns an Array Iteration Object, containing the values of the original array\n\n```javascript\nlet array = ['a', 'b', 'c'];\n\nlet iterator = array.values();\n\nconsole.log(array); // Output: [\"a\", \"b\", \"c\"]\nconsole.log(iterator.next().value); // Output: \"a\"\n```\n\n**with()** - Allows you to add properties and methods to an Array object\n\n```javascript\nlet array = ['a', 'b', 'c'];\n\nArray.with = 25;\n\nconsole.log(array); // Output: [\"a\", \"b\", \"c\"]\nconsole.log(Array.with); // Output: 25\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Strings\n\nStrings are used to store text. Strings must be enclosed in single or double quotes.\n\n```javascript\nconst name = 'Manthan';\n```\n\n### Strings methods\n\nThe following are some of the most commonly used string methods in JavaScript:\n\n- **at()**\n- **charAt()**\n- **charCodeAt()**\n- **concat()**\n- **constructor**\n- **endsWith()**\n- **fromCharCode()**\n- **includes()**\n- **indexOf()**\n- **lastIndexOf()**\n- **length**\n- **localeCompare()**\n- **match()**\n- **matchAll()**\n- **padEnd()**\n- **padStart()**\n- **prototype**\n- **repeat()**\n- **replace()**\n- **replaceAll()**\n- **search()**\n- **slice()**\n- **split()**\n- **startsWith()**\n- **substr()**\n- **substring()**\n- **toLocaleLowerCase()**\n- **toLocaleUpperCase()**\n- **toLowerCase()**\n- **toString()**\n- **toUpperCase()**\n- **trim()**\n- **trimEnd()**\n- **trimStart()**\n- **valueOf()**\n\n[Back to Top⤴️](#table-of-contents)\n\n**at()** - Returns the character at a specified index (position)\n\n```javascript\nlet myString = \"Hello World!\";\n\nconsole.log(myString.at(0)); // Output: \"H\"\n```\n\n**charAt()** - Returns the character at a specified index (position)\n\n```javascript\nlet myString = \"Hello World!\";\n\nconsole.log(myString.charAt(0)); // Output: \"H\"\n```\n\n**charCodeAt()** - Returns the Unicode of the character at a specified index\n\n```javascript\nlet myString = \"Hello World!\";\n\nconsole.log(myString.charCodeAt(0)); // Output: 72\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**concat()** - Returns two or more joined strings\n\n```javascript\nlet myString1 = \"Hello\";\nlet myString2 = \"World!\";\n\nlet newString = myString1.concat(\" \", myString2);\n\nconsole.log(newString); // Output: \"Hello World!\"\n```\n\n**constructor** - Returns the string's constructor function\n\n```javascript\nlet myString = \"Hello World!\";\n\nconsole.log(myString.constructor); // Output: ƒ String() { [native code] }\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**endsWith()** - Returns if a string ends with a specified value\n\n```javascript\nlet myString = \"Hello World!\";\n\nconsole.log(myString.endsWith(\"!\")); // Output: true\n```\n\n**fromCharCode()** - Returns Unicode values as characters\n\n```javascript\nlet myString = String.fromCharCode(72, 101, 108, 108, 111);\n\nconsole.log(myString); // Output: \"Hello\"\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**includes()** - Returns if a string contains a specified value\n\n```javascript\nlet myString = \"Hello World!\";\n\nconsole.log(myString.includes(\"World\")); // Output: true\n```\n\n**indexOf()** - Returns the index (position) of the first occurrence of a value in a string\n\n```javascript\nlet myString = \"Hello World!\";\n\nconsole.log(myString.indexOf(\"World\")); // Output: 6\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**lastIndexOf()** - Returns the index (position) of the last occurrence of a value in a string\n\n```javascript\nlet myString = \"Hello World! World!\";\n\nconsole.log(myString.lastIndexOf(\"World\")); // Output: 13\n```\n\n**length** - Returns the length of a string\n\n```javascript\nlet myString = \"Hello World!\";\n\nconsole.log(myString.length); // Output: 12\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**localeCompare()** - Compares two strings in the current locale\n\n```javascript\nlet myString = \"Hello World!\";\n\nconsole.log(myString.localeCompare(\"Hello World!\")); // Output: 0\n```\n\n**match()** - Searches a string for a value, or a regular expression, and returns the matches\n\n```javascript\nlet myString = \"The quick brown fox jumps over the lazy dog.\";\n\nlet result = myString.match(/the/i);\n\nconsole.log(myString); // Output: \"The quick brown fox jumps over the lazy dog.\"\nconsole.log(result); // Output: [\"the\", index: 30, input: \"The quick brown fox jumps over the lazy dog.\", groups: undefined]\n```\n\n**matchAll()** - Returns an iterator of all results matching a string against a regular expression\n\n```javascript\nlet myString = \"The quick brown fox jumps over the lazy dog.\";\n\nlet result = myString.matchAll(/the/gi);\n\nconsole.log(myString); // Output: \"The quick brown fox jumps over the lazy dog.\"\nconsole.log(result); // Output: [RegExpStringIterator]\n```\n\n**padEnd()** - Pads a string with a specified value at the end\n\n```javascript\nlet myString = \"Hello\";\n\nlet newString = myString.padEnd(10, \" World!\");\n\nconsole.log(myString); // Output: \"Hello\"\nconsole.log(newString); // Output: \"Hello World!\"\n```\n\n**padStart()** - Pads a string with a specified value at the start\n\n```javascript\nlet myString = \"Hello\";\n\nlet newString = myString.padStart(10, \" World!\");\n\nconsole.log(myString); // Output: \"Hello\"\nconsole.log(newString); // Output: \" World!Hello\"\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**prototype** - Allows you to add properties and methods to an object\n\n```javascript\nlet myString = \"Hello World!\";\nString.prototype.age = 25;\n\nconsole.log(myString.age); // Output: 25\n```\n\n**repeat()** - Returns a new string with a number of copies of a string\n\n```javascript\nlet myString = \"Hello World!\";\n\nconsole.log(myString.repeat(2)); // Output: \"Hello World!Hello World!\"\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**replace()** - Searches a string for a value, or a regular expression, and returns a string where the values are replaced\n\n```javascript\nlet myString = \"Hello World!\";\n\nlet newString = myString.replace(\"World\", \"Universe\");\n\nconsole.log(myString); // Output: \"Hello World!\"\nconsole.log(newString); // Output: \"Hello Universe!\"\n```\n\n**search()** - Searches a string for a value, or regular expression, and returns the index (position) of the match\n\n```javascript\nlet myString = \"The quick brown fox jumps over the lazy dog.\";\n\nlet result = myString.search(/fox/);\n\nconsole.log(myString); // Output: \"The quick brown fox jumps over the lazy dog.\"\nconsole.log(result); // Output: 16\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**slice()** - Extracts a part of a string and returns a new string\n\n```javascript\nlet myString = \"Hello World!\";\n\nlet newString = myString.slice(6, 11);\n\nconsole.log(myString); // Output: \"Hello World!\"\nconsole.log(newString); // Output: \"World\"\n```\n\n**split()** - Splits a string into an array of substrings\n\n```javascript\nlet myString = \"Hello World!\";\n\nlet array = myString.split(\" \");\n\nconsole.log(myString); // Output: \"Hello World!\"\nconsole.log(array); // Output: [\"Hello\", \"World!\"]\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**startsWith()** - Checks whether a string begins with specified characters\n\n```javascript\nlet myString = \"Hello World!\";\n\nconsole.log(myString.startsWith(\"Hello\")); // Output: true\n```\n\n**substr()** - Extracts a number of characters from a string, from a start index (position)\n\n```javascript\nlet myString = \"Hello World!\";\n\nlet newString = myString.substr(6, 5);\n\nconsole.log(myString); // Output: \"Hello World!\"\nconsole.log(newString); // Output: \"World\"\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**substring()** - Extracts characters from a string, between two specified indices (positions)\n\n```javascript\nlet myString = \"Hello World!\";\n\nlet newString = myString.substring(6, 11);\n\nconsole.log(myString); // Output: \"Hello World!\"\nconsole.log(newString); // Output: \"World\"\n```\n\n**toLocaleLowerCase()** - Returns a string converted to lowercase letters, using the host's locale\n\n```javascript\nlet myString = \"Hello World!\";\n\nconsole.log(myString.toLocaleLowerCase()); // Output: \"hello world!\"\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**toLocaleUpperCase()** - Returns a string converted to uppercase letters, using the host's locale\n\n```javascript\nlet myString = \"Hello World!\";\n\nconsole.log(myString.toLocaleUpperCase()); // Output: \"HELLO WORLD!\"\n```\n\n**toLowerCase()** - Returns a string converted to lowercase letters\n\n```javascript\nlet myString = \"Hello World!\";\n\nconsole.log(myString); // Output: \"Hello World!\"\nconsole.log(myString.toLowerCase()); // Output: \"hello world!\"\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**toString()** - Returns a string or a string object as a string\n\n```javascript\nlet myString = \"Hello World!\";\nlet number = 25; \n\nconsole.log(myString.toString()); // Output: \"Hello World!\"\nconsole.log(number.toString()); // Output: \"25\"\n```\n\n**toUpperCase()** - Returns a string converted to uppercase letters\n\n```javascript\nlet myString = \"Hello World!\";\n\nconsole.log(myString); // Output: \"Hello World!\"\nconsole.log(myString.toUpperCase()); // Output: \"HELLO WORLD\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**trim()** - Returns a string with removed whitespaces\n\n```javascript\nlet myString = \" Hello World! \";\n\nconsole.log(myString); // Output: \" Hello World! \"\nconsole.log(myString.trim()); // Output: \"Hello World!\"\n```\n\n**trimEnd()** - Returns a string with removed whitespaces from the end\n\n```javascript\nlet myString = \" Hello World! \";\n\nconsole.log(myString); // Output: \" Hello World! \"\nconsole.log(myString.trimEnd()); // Output: \" Hello World!\"\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**trimStart()** - Returns a string with removed whitespaces from the start\n\n```javascript\nlet myString = \" Hello World! \";\n\nconsole.log(myString); // Output: \" Hello World! \"\nconsole.log(myString.trimStart()); // Output: \"Hello World! \"\n```\n\n**valueOf()** - Returns the primitive value of a string or a string object.\n\n```javascript\nlet myString = \"Hello World!\";\n\nconsole.log(myString.valueOf()); // Output: \"Hello World!\"\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Objects\n\nObjects are used to store collections of data and more complex entities.\n\n```javascript\nconst person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n  age: 25,\n  hobbies: [\"reading\", \"coding\", \"traveling\"],\n  address: {\n    street: \"123 Main St\",\n    city: \"Mumbai\",\n    state: \"MH\",\n  },\n};\n```\n\n### Object Methods\n\nThe following are some of the most commonly used object methods in JavaScript:\n\n- **assign()**\n- **create()**\n- **defineProperties()**\n- **defineProperty()**\n- **entries()**\n- **freeze()**\n- **fromEntries()**\n- **getOwnPropertyDescriptor()**\n- **getOwnPropertyDescriptors()**\n- **getOwnPropertyNames()**\n- **getOwnPropertySymbols()**\n- **getPrototypeOf()**\n- **groupBy()**\n- **hasOwn()**\n- **is()**\n- **isExtensible()**\n- **isFrozen()**\n- **isSealed()**\n- **keys()**\n- **preventExtensions()**\n- **prototype**\n- **seal()**\n- **setPrototypeOf()**\n- **values()**\n\n[Back to Top⤴️](#table-of-contents)\n\n**assign()** - Copies the values of all enumerable own properties from one or more source objects to a target object\n\n```javascript\nconst person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nconst details = {\n  age: 25,\n  hobbies: [\"reading\", \"coding\", \"traveling\"],\n};\n\nconst newPerson = Object.assign(person, details);\n\nconsole.log(newPerson); // Output: {firstName: \"Manthan\", lastName: \"Ank\", age: 25, hobbies: Array(3)}\n```\n\n**create()** - Creates a new object with the specified prototype object and properties\n\n```javascript\nconst person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nconst newPerson = Object.create(person);\n\nconsole.log(newPerson); // Output: {}\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**defineProperties()** - Defines new or modifies existing properties directly on an object, returning the object\n\n```javascript\nconst person = {};\n\nObject.defineProperties(person, {\n  firstName: {\n    value: \"Manthan\",\n    writable: true,\n  },\n  lastName: {\n    value: \"Ank\",\n    writable: true,\n  },\n});\n\nconsole.log(person); // Output: {firstName: \"Manthan\", lastName: \"Ank\"}\n```\n\n**defineProperty()** - Defines a new property directly on an object, or modifies an existing property on an object, and returns the object\n\n```javascript\nconst person = {};\n\nObject.defineProperty(person, \"firstName\", {\n  value: \"Manthan\",\n  writable: true,\n});\n\nconsole.log(person); // Output: {firstName: \"Manthan\"}\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**entries()** - Returns an array of a given object's own enumerable string-keyed property [key, value] pairs\n\n```javascript\nconst person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nconst entries = Object.entries(person);\n\nconsole.log(entries); // Output: [[\"firstName\", \"Manthan\"], [\"lastName\", \"Ank\"]]\n```\n\n**freeze()** - Freezes an object: other code can't delete or change any properties\n\n```javascript\nconst person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nObject.freeze(person);\n\nperson.age = 25;\n\nconsole.log(person); // Output: {firstName: \"Manthan\", lastName: \"Ank\"}\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**fromEntries()** - Returns a new object from an iterable of [key, value] pairs\n\n```javascript\nconst entries = [\n  [\"firstName\", \"Manthan\"],\n  [\"lastName\", \"Ank\"],\n];\n\nconst person = Object.fromEntries(entries);\n\nconsole.log(person); // Output: {firstName: \"Manthan\", lastName: \"Ank\"}\n```\n\n**getOwnPropertyDescriptor()** - Returns a property descriptor for a named property on an object\n\n```javascript\nconst person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nconst descriptor = Object.getOwnPropertyDescriptor(person, \"firstName\");\n\nconsole.log(descriptor); // Output: {value: \"Manthan\", writable: true, enumerable: true, configurable: true}\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**getOwnPropertyDescriptors()** - Returns all own property descriptors of a given object\n\n```javascript\nconst person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nconst descriptors = Object.getOwnPropertyDescriptors(person);\n\nconsole.log(descriptors); // Output: {firstName: {…}, lastName: {…}}\n```\n\n**getOwnPropertyNames()** - Returns an array of all properties (enumerable or not) found directly upon a given object\n\n```javascript\nconst person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nconst properties = Object.getOwnPropertyNames(person);\n\nconsole.log(properties); // Output: [\"firstName\", \"lastName\"]\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**getOwnPropertySymbols()** - Returns an array of all symbol properties found directly upon a given object\n\n```javascript\nconst person = {\n  [Symbol(\"firstName\")]: \"Manthan\",\n  [Symbol(\"lastName\")]: \"Ank\",\n};\n\nconst symbols = Object.getOwnPropertySymbols(person);\n\nconsole.log(symbols); // Output: [Symbol(firstName), Symbol(lastName)]\n```\n\n**getPrototypeOf()** - Returns the prototype of the specified object\n\n```javascript\nconst person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nconst prototype = Object.getPrototypeOf(person);\n\nconsole.log(prototype); // Output: {constructor: ƒ, __defineGetter__: ƒ, __defineSetter__: ƒ, hasOwnProperty: ƒ, __lookupGetter__: ƒ, …}\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**groupBy()** - Groups the elements of an array based on the given function\n\n```javascript\nconst people = [\n  { name: \"Manthan\", age: 25 },\n  { name: \"Ank\", age: 30 },\n  { name: \"John\", age: 25 },\n];\n\nconst groupedPeople = people.groupBy(person =\u003e person.age);\n\nconsole.log(groupedPeople); // Output: {25: Array(2), 30: Array(1)}\n```\n\n**hasOwn()** - Returns a boolean indicating whether the object has the specified property as its own property\n\n```javascript\nconst person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nconsole.log(person.hasOwn(\"firstName\")); // Output: true\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**is()** - Compares if two values are the same value\n\n```javascript\nconst person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nconst newPerson = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nconsole.log(Object.is(person, newPerson)); // Output: false\n```\n\n**isExtensible()** - Returns a boolean indicating if the object is extensible\n\n```javascript\nconst person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nconsole.log(Object.isExtensible(person)); // Output: true\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**isFrozen()** - Returns a boolean indicating if the object is frozen\n\n```javascript\nconst person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nObject.freeze(person);\n\nconsole.log(Object.isFrozen(person)); // Output: true\n```\n\n**isSealed()** - Returns a boolean indicating if the object is sealed\n\n```javascript\nconst person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nObject.seal(person);\n\nconsole.log(Object.isSealed(person)); // Output: true\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**keys()** - Returns an array of a given object's own enumerable property names\n\n```javascript\nconst person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nconst keys = Object.keys(person);\n\nconsole.log(keys); // Output: [\"firstName\", \"lastName\"]\n```\n\n**preventExtensions()** - Prevents any extensions of an object\n\n```javascript\nconst person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nObject.preventExtensions(person);\n\nperson.age = 25;\n\nconsole.log(person); // Output: {firstName: \"Manthan\", lastName: \"Ank\"}\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**prototype** - Allows you to add properties and methods to an object\n\n```javascript\nconst person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nObject.prototype.age = 25;\n\nconsole.log(person.age); // Output: 25\n```\n\n**seal()** - Prevents other code from deleting properties of an object\n\n```javascript\nconst person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nObject.seal(person);\n\ndelete person.firstName;\n\nconsole.log(person); // Output: {firstName: \"Manthan\", lastName: \"Ank\"}\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**setPrototypeOf()** - Sets the prototype (i.e., the internal [[Prototype]] property) of a specified object to another object or null\n\n```javascript\nconst person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nconst newPerson = {\n  age: 25,\n};\n\nObject.setPrototypeOf(newPerson, person);\n\nconsole.log(newPerson); // Output: {age: 25}\n```\n\n**values()** - Returns an array of a given object's own enumerable property values\n\n```javascript\nconst person = {\n  firstName: \"Manthan\",\n  lastName: \"Ank\",\n};\n\nconst values = Object.values(person);\n\nconsole.log(values); // Output: [\"Manthan\", \"Ank\"]\n```\n\n## Loops\n\nLoops are used to execute a block of code multiple times.\n\nThere are several types of loops in JavaScript:\n\n- for loop\n- while loop\n- do while loop\n- for in loop\n- for of loop\n\n[Back to Top⤴️](#table-of-contents)\n\n### for loop\n\nThis type of loop is used to execute a block of code a specified number of times.\n\n```javascript\nfor (let i = 0; i \u003c 5; i++) {\n  console.log(i);\n}\n```\n\n### while loop\n\nThis type of loop is used to execute a block of code as long as a specified condition is true.\n\n```javascript\nlet i = 0;\nwhile (i \u003c 5) {\n  console.log(i);\n  i++;\n}\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### do while loop\n\nThis type of loop is similar to the while loop, but it guarantees that the code block will be executed at least once.\n\n```javascript\nlet i = 0;\ndo {\n  console.log(i);\n  i++;\n} while (i \u003c 5);\n```\n\n### for in loop\n\nThis type of loop is used to iterate over the enumerable properties of an object.\n\n```javascript\nlet obj = {a: 1, b: 2, c: 3};\nfor (let prop in obj) {\n  console.log(prop + \": \" + obj[prop]);\n}\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### for of loop\n\nThis type of loop is used to iterate over the iterable objects such as arrays, strings, and maps.\n\n```javascript\nlet arr = [1, 2, 3];\nfor (let value of arr) {\n  console.log(value);\n}\n```\n\n## Conditional Statements\n\nConditional statements are used to perform different actions based on different conditions.\n\nThere are several types of conditional statements in JavaScript:\n\n- if statement\n- if else statement\n- if else else if statement\n- switch statement\n\n[Back to Top⤴️](#table-of-contents)\n\n## if statement\n\nThe if statement is used to execute a block of code if a specified condition is true.\n\n```javascript\nif (x \u003e 0) {\n  console.log(\"x is greater than 0\");\n}\n```\n\n### if else statement\n\nThe if...else statement is used to execute a block of code if a specified condition is true and another block of code if the condition is false.\n\n```javascript\nif (x \u003e 0) {\n  console.log(\"x is greater than 0\");\n} else {\n  console.log(\"x is not greater than 0\");\n}\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### if else else if statement\n\nThe if...else if...else statement is used to specify multiple conditions and execute a different block of code for each one.\n\n```javascript\nif (x \u003e 0) {\n  console.log(\"x is positive\");\n} else if (x \u003c 0) {\n  console.log(\"x is negative\");\n} else {\n  console.log(\"x is zero\");\n}\n```\n\n### switch statement\n\nThe switch statement is used to select one of many blocks of code to be executed.\n\n```javascript\nlet day = new Date().getDay();\nswitch (day) {\n  case 0:\n    console.log(\"Sunday\");\n    break;\n  case 1:\n    console.log(\"Monday\");\n    break;\n  case 2:\n    console.log(\"Tuesday\");\n    break;\n  // and so on\n  default:\n    console.log(\"Invalid day\");\n}\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Functions\n\nFunctions are blocks of code that can be reused to perform a specific task. Defined with the function keyword, followed by a name, followed by parentheses ().\n\n```jsx\nfunction name(parameter1, parameter2, parameter3) {\n  // code to be executed\n}\n```\n\n### Types of Functions\n\n- Named Function\n- Anonymous Function\n- Arrow Function\n- IIFE\n- Higher-Order Function\n- Function Expression\n- Function Declaration\n- Function Constructor\n\n[Back to Top⤴️](#table-of-contents)\n\n### Named Function\n\nA named function is a function that has a name. It can be defined using the function keyword followed by the function name.\n\n```javascript\nfunction name(parameter1, parameter2, parameter3) {\n  // code to be executed\n}\n```\n\n### Anonymous Function\n\nAn anonymous function is a function that does not have a name. It can be defined using the function keyword followed by parentheses ().\n\n```javascript\nconst name = function(parameter1, parameter2, parameter3) {\n  // code to be executed\n}\n```\n\n### Arrow Function\n\nArrow functions are a more concise way to write functions in JavaScript. They are defined using the =\u003e syntax.\n\n```javascript\nconst name = (parameter1, parameter2, parameter3) =\u003e {\n  // code to be executed\n}\n\nconst name = (parameter1, parameter2, parameter3) =\u003e expression\n\nconst name = parameter =\u003e expression\n\nconst name = () =\u003e expression\n\nconst name = (parameter1, parameter2, parameter3) =\u003e {\n  return expression\n}\n\nconst name = parameter =\u003e {\n  return expression\n}\n\nconst name = () =\u003e {\n  return expression\n}\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## IIFE\n\nAn IIFE (Immediately Invoked Function Expression) is a JavaScript function that runs as soon as it is defined.\n\n```javascript\n(function() {\n  console.log(\"Hello World!\");\n})();\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Higher-Order Functions\n\nA higher-order function is a function that takes another function as an argument or returns a function as a result.\n\n```javascript\nfunction greet() {\n  return \"Hello World!\";\n}\n\nfunction greetUser(greet) {\n  return greet();\n}\n\nconsole.log(greetUser(greet)); // Output: \"Hello World!\"\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Function Expression\n\nA function expression is a function that is assigned to a variable.\n\n```javascript\nconst greet = function() {\n  return \"Hello World!\";\n}\n\nconsole.log(greet()); // Output: \"Hello World!\"\n```\n\n## Function Declaration\n\nA function declaration is a function that is defined using the function keyword followed by the function name.\n\n```javascript\nfunction greet() {\n  return \"Hello World!\";\n}\n\nconsole.log(greet()); // Output: \"Hello World!\"\n```\n\n### Function Constructor\n\nA function constructor is a function that is used to create new objects.\n\n```javascript\nconst greet = new Function(\"return 'Hello World!'\");\nconsole.log(greet()); // Output: \"Hello World!\"\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Scope\n\nScope refers to the visibility of variables in JavaScript. There are three types of scope in JavaScript:\n\n- Global Scope\n- Function Scope\n- Block Scope\n\n### Global Scope\n\n```javascript\nlet a = 10;\nfunction myFunction() {\n    console.log(a);\n}\nmyFunction();\n```\n\n### Block Scope\n\n```javascript\n//var\nfunction myFunction () {\n    if(true) {\n        var a = 10; // it exists in function scope\n    }\n    console.log(a);\n}\nmyFunction();\n\n//let\nfunction myFunction () {\n    if(true) {\n        let a = 10; // it exists in block scope\n    }\n    console.log(a);\n}\nmyFunction();\n\n//const\nfunction myFunction () {\n    if(true) {\n        const a = 10; // it exists in block scope\n    }\n    console.log(a);\n}\nmyFunction();\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### Function Scope\n\n```javascript\n//var\nfunction myFunction() {\n    var a = 10;\n}\nmyFunction()\nconsole.log(a);\n\n//let\nfunction myFunction() {\n    let a = 10;\n}\nmyFunction()\nconsole.log(a);\n\n//const\nfunction myFunction() {\n    const a = 10;\n}\nmyFunction()\nconsole.log(a);\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Hoisting\n\nHoisting is a JavaScript mechanism where variables and function declarations are moved to the top of their containing scope during the compilation phase.\n\n```javascript\nconsole.log(x); // Output: undefined\n\nvar x = 5;\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Currying\n\nCurrying is a technique in which a function with multiple arguments is converted into a sequence of nested functions, each taking a single argument.\n\n```javascript\nfunction multiply(a) {\n  return function(b) {\n    return function(c) {\n      return a * b * c;\n    };\n  };\n}\n\nconsole.log(multiply(2)(3)(4)); // Output: 24\n```\n\n## Dates\n\nJavaScript provides a built-in Date object that can be used to work with dates and times.\n\n### Date Object\n\nThe Date object is used to work with dates and times in JavaScript. It can be created using the new keyword followed by the Date() constructor.\n\n```javascript\nnew Date()\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### Date Formats\n\nThere are several ways to create a new Date object in JavaScript:\n\n```javascript\nnew Date() // current date and time\nnew Date(milliseconds) // milliseconds since January 1, 1970, 00:00:00 UTC\nnew Date(dateString) // date string (e.g. \"October 13, 2014 11:13:00\")\nnew Date(year, month, day, hours, minutes, seconds, milliseconds) // year, month, day, hours, minutes, seconds, milliseconds\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### Date Properties\n\n**constructor** - Returns the function that created the Date object's prototype\n\n```javascript\nconst d = new Date();\nd.constructor; // ƒ Date() { [native code] }\n```\n\n**prototype** - Allows you to add properties and methods to the Date object\n\n```javascript\nDate.prototype.age = 25;\n\nconst d = new Date();\nd.age; // 25\n```\n\n**UTC** - Returns the number of milliseconds since January 1, 1970, 00:00:00 UTC\n\n```javascript\nconst d = new Date();\nd.UTC(); // 1642149980524\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**parse** - Parses a date string and returns the number of milliseconds since January 1, 1970, 00:00:00 UTC\n\n```javascript\nDate.parse(\"Jan 1, 2023\"); // 1672531200000\n```\n\n**now** - Returns the number of milliseconds since January 1, 1970, 00:00:00 UTC\n\n```javascript\nDate.now(); // 1642149980524\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### Date Methods\n\n**toString** - It is a built-in function that can be used to convert a date object to a string.\n\n```javascript\nconst d = new Date();\nd.toString(); // 'Sat Jan 14 2023 10:36:20 GMT+0530 (India Standard Time)'\n```\n\n**toDateString** - It is a built-in function that can be used to convert a date object to a string in the format of \"Weekday Month Date Year\".\n\n```javascript\nconst d = new Date();\nd.toDateString(); // 'Sat Jan 14 2023'\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**toUTCString** - It is a built-in function that can be used to convert a date object to a string in the format of \"Weekday, DD Mon YYYY HH:MM:SS GMT\".\n\n```javascript\nconst d = new Date();\nd.toUTCString(); // 'Sat, 14 Jan 2023 05:06:20 GMT'\n```\n\n**toISOString** - It is a built-in function that can be used to convert a date object to a string in the format of \"YYYY-MM-DDTHH:mm:ss.sssZ\".\n\n```javascript\nconst d = new Date();\nd.toISOString(); // '2023-01-14T05:06:20.524Z'\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Date Get Methods\n\nThe Date object has several built-in methods that can be used to get the date and time components of a date object. Some of the most commonly used get methods are:\n\n**getFullYear** - returns the four-digit year of the date.\n\n```javascript\nconst d = new Date();\nd.getFullYear();\n```\n\n**getMonth** - returns the month of the date (0-11, where 0 represents January and 11 represents December).\n\n```javascript\nconst d = new Date();\nd.getMonth();\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**getDate** - returns the day of the month of the date (1-31).\n\n```javascript\nconst d = new Date();\nd.getDate();\n```\n\n**getDay** - returns the day of the week of the date (0-6, where 0 represents Sunday and 6 represents Saturday).\n\n```javascript\nconst d = new Date();\nd.getDay();\n```\n\n**getHours** - returns the hour of the date (0-23).\n\n```javascript\nconst d = new Date();\nd.getHours();\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**getMinutes** - returns the minutes of the date (0-59).\n\n```javascript\nconst d = new Date();\nd.getMinutes();\n```\n\n**getSeconds** - returns the seconds of the date (0-59).\n\n```javascript\nconst d = new Date();\nd.getSeconds();\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**getMilliseconds** - returns the milliseconds of the date (0-999).\n\n```javascript\nconst d = new Date();\nd.getMilliseconds();\n```\n\n**getTime** - returns the number of milliseconds since January 1, 1970, 00:00:00 UTC.\n\n```javascript\nconst d = new Date();\nd.getTime();\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Date Set Methods\n\n**setDate** - sets the day of the month of the date object.\n\n```javascript\nconst d = new Date();\nd.setDate(15);\n```\n\n**setFullYear** - sets the year, and optionally the month and date, of the date object.\n\n```javascript\nconst d = new Date();\nd.setFullYear(2020);\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**setHours** - sets the hours, minutes, seconds and milliseconds of the date object.\n\n```javascript\nconst d = new Date();\nd.setHours(22);\n```\n\n**setMilliseconds** - sets the milliseconds of the date object.\n\n```javascript\nconst d = new Date();\nd.setMilliSeconds(3000);\n```\n\n**setMinutes** - sets the minutes, seconds and milliseconds of the date object.\n\n```javascript\nconst d = new Date();\nd.setMinutes(30);\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**setSeconds** - sets the seconds and milliseconds of the date object.\n\n```javascript\nconst d = new Date();\nd.setSeconds(30);\n```\n\n**setMonth** - sets the month, and optionally the date, of the date object.\n\n```javascript\nconst d = new Date();\nd.setMonth(11);\n```\n\n**setTime** - sets the date object to the time represented by a number of milliseconds since January 1, 1970, 00:00:00 UTC.\n\n```javascript\nconst d = new Date();\nd.setTime(30);\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Type Conversion\n\nJavaScript is a loosely typed language, which means that variables can hold values of any data type. JavaScript automatically converts the data type of a variable to the appropriate type when needed.\n\n### Convert string to numbers\n\n**Number** - Converts a string to a number using the Number() function.\n\n```javascript\nNumber(\"3.14\") // 3.14\nNumber(Math.PI) // 3.141592653589793\nNumber(\" \") // 0\nNumber(\"\") // 0\nNumber(\"99 88\") // NaN\nNumber(\"John\") // NaN\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**parseFloat** - Converts a string to a floating-point number using the parseFloat() method.\n\n```javascript\nlet num = parseFloat(\"123.456\");\nconsole.log(num); // Output: 123.456\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**parseInt** - Converts a string to an integer using the parseInt() method.\n\n```javascript\nlet num = parseInt(\"123\");\nconsole.log(num); // Output: 123\n```\n\n### Convert number to a string\n\n**String** - Converts a number to a string using the String() method.\n\n```javascript\nlet str = String(123);\nconsole.log(str); // Output: \"123\"\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**toString** - Converts a number to a string using the toString() method.\n\n```javascript\nlet str = (123).toString();\nconsole.log(str); // Output: \"123\"\n```\n\n**toExponential** - Converts a number to a string, using toExponential() method.\n\n```javascript\nlet str = (123).toExponential();\nconsole.log(str); // Output: 1.23e+2\n```\n\n**toFixed** - Converts a number to a string, using toFixed() method.\n\n```javascript\nlet str = (123).toFixed();\nconsole.log(str); // Output: 123\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**toPrecision** - Converts a number to a string, using toPrecision() method.\n\n```javascript\nlet str = (123).toPrecision();\nconsole.log(str); // Output: 123\n```\n\n### Convert dates to numbers\n\n**Number** - Converts a date to a number using the Number() function.\n\n```javascript\nd = new Date();\nNumber(d) // 1673677425068\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**getTime** Converts a date to a number using the getTime() method.\n\n```javascript\nd = new Date();\nd.getTime() // 1673677461233\n```\n\n**string** - Converts a date to a string using the String() function.\n\n```javascript\nString(Date()) // 'Sat Jan 14 2023 11:54:38 GMT+0530 (India Standard Time)'\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**toString** - Converts a date to a string using the toString() method.\n\n```javascript\nDate().toString() //'Sat Jan 14 2023 11:54:57 GMT+0530 (India Standard Time)'\n```\n\n### Convert boolean to number\n\n**Number** - Converts a boolean to a number using the Number() function.\n\n```javascript\nNumber(false)     // returns 0\nNumber(true)      // returns 1\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### Convert boolean to string\n\n**string** - Converts a boolean to a string using the String() function.\n\n```javascript\nString(false)      // returns \"false\"\nString(true)       // returns \"true\"\n```\n\n| Original Value | Converted to Number | Converted to String | Converted to Boolean |\n|---|---|---|---|\n| false | 0 | \"false\" | false |\n| true | 1 | \"true\" | true |\n| 0 | 0 | \"0\" | false |\n| 1 | 1 | \"1\" | true |\n| \"0\" | 0 | \"0\" | true |\n| \"000\" | 0 | \"000\" | true |\n| \"1\" | 1 | \"1\" | true |\n| NaN | NaN | \"NaN\" | false |\n| Infinity | Infinity | \"Infinity\" | true |\n| -Infinity | -Infinity | \"-Infinity\" | true |\n| \"\" | 0 | \"\" | false |\n| \"20\" | 20 | \"20\" | true |\n| \"twenty\" | NaN | \"twenty\" | true |\n| [ ] | 0 | \"\" | true |\n| [20] | 20 | \"20\" | true |\n| [10,20] | NaN | \"10,20\" | true |\n| [\"twenty\"] | NaN | \"twenty\" | true |\n| [\"ten\",\"twenty\"] | NaN | \"ten,twenty\" | true |\n| function(){} | NaN | \"function(){}\" | true |\n| { } | NaN | \"[object Object]\" | true |\n| null | 0 | \"null\" | false |\n| undefined | NaN | \"undefined\" | false |\n\n[Back to Top⤴️](#table-of-contents)\n\n## Typeof\n\nThe typeof operator is used to get the data type of a variable or an expression.\n\n```javascript\ntypeof \"John\"                 // Returns \"string\"\ntypeof 3.14                   // Returns \"number\"\ntypeof NaN                    // Returns \"number\"\ntypeof false                  // Returns \"boolean\"\ntypeof [1,2,3,4]              // Returns \"object\"\ntypeof {name:'John', age:34}  // Returns \"object\"\ntypeof new Date()             // Returns \"object\"\ntypeof function () {}         // Returns \"function\"\ntypeof myCar                  // Returns \"undefined\" *\ntypeof null                   // Returns \"object\"\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nKeep in mind that\n\n- The data type of NaN is number\n- The data type of an array is object\n- The data type of a date is object\n- The data type of null is object\n- The data type of an undefined variable is undefined *\n- The data type of a variable that has not been assigned a value is also undefined *\n\n## Math\n\nThe Math object allows you to perform mathematical tasks on numbers.\n\n```javascript\nMath.PI // returns 3.141592653589793\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### Math Property\n\n```javascript\nMath.property\n```\n\nExample\n\n```javascript\nMath.E        // returns Euler's number\nMath.PI       // returns PI\nMath.SQRT2    // returns the square root of 2\nMath.SQRT1_2  // returns the square root of 1/2\nMath.LN2      // returns the natural logarithm of 2\nMath.LN10     // returns the natural logarithm of 10\nMath.LOG2E    // returns base 2 logarithm of E\nMath.LOG10E   // returns base 10 logarithm of E\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### Math Methods\n\nThe Math object has several built-in methods that can be used to perform mathematical tasks. Some of the most commonly used methods are:\n\n**Math.round** - Returns x rounded to its nearest integer\n\n```javascript\nMath.round(4.6); // 5\n```\n\n**Math.ceil** - Returns x rounded up to its nearest integer\n\n```javascript\nMath.ceil(4.4); // 5\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**Math.floor** - Returns x rounded down to its nearest integer\n\n```javascript\nMath.floor(4.7); // 4\n```\n\n**Math.trunc** - Returns the integer part of x (new in ES6)\n\n```javascript\nMath.trunc(4.7); // 4\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**Math.sign** - Returns if x is negative, null or positive.\n\n```javascript\nMath.sign(4); // 1\n```\n\n**Math.pow** - returns the value of x to the power of y.\n\n```javascript\nMath.pow(8, 2); // 64\n```\n\n**Math.sqrt** - returns the square root of x.\n\n```javascript\nMath.sqrt(64); // 8\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**Math.abs** - returns the absolute (positive) value of x.\n\n```javascript\nMath.abs(-4.7); // 4.7\n```\n\n**Math.sin** - returns the sine (a value between -1 and 1) of the angle x (given in radians).\n\n```javascript\nMath.sin(90 * Math.PI / 180);     // returns 1 (the sine of 90 degrees)\n```\n\n**Math.cos** - returns the cosine (a value between -1 and 1) of the angle x (given in radians).\n\n```javascript\nMath.cos(0 * Math.PI / 180);     // returns 1 (the cos of 0 degrees)\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**Math.min** - It can be used to find the lowest value in a list of arguments.\n\n```javascript\nMath.min(0, 150, 30, 20, -8, -200); // -200\n```\n\n**Math.max** - It can be used to find the highest value in a list of arguments.\n\n```javascript\nMath.max(0, 150, 30, 20, -8, -200); // 150\n```\n\n**Math.random** - returns a random number between 0 (inclusive), and 1 (exclusive).\n\n```javascript\nMath.random(); // 0.07840484495533051\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**Math.log** - returns the natural logarithm of x.\n\n```javascript\nMath.log(1); // 0\n```\n\n**Math.log2** - returns the base 2 logarithm of x.\n\n```javascript\nMath.log2(8); // 3\n```\n\n**Math.log10** - returns the base 10 logarithm of x.\n\n```javascript\nMath.log10(1000); // 3\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n| Method | Description |\n|---|---|\n| abs(x) | Returns the absolute value of x |\n| acos(x) | Returns the arccosine of x, in radians |\n| acosh(x) | Returns the hyperbolic arccosine of x |\n| asin(x) | Returns the arcsine of x, in radians |\n| asinh(x) | Returns the hyperbolic arcsine of x |\n| atan(x) | Returns the arctangent of x as a numeric value between -PI/2 and PI/2 radians |\n| atan2(y, x) | Returns the arctangent of the quotient of its arguments |\n| atanh(x) | Returns the hyperbolic arctangent of x |\n| cbrt(x) | Returns the cubic root of x |\n| ceil(x) | Returns x, rounded upwards to the nearest integer |\n| cos(x) | Returns the cosine of x (x is in radians) |\n| cosh(x) | Returns the hyperbolic cosine of x |\n| exp(x) | Returns the value of Ex |\n| floor(x) | Returns x, rounded downwards to the nearest integer |\n| log(x) | Returns the natural logarithm (base E) of x |\n| max(x, y, z, ..., n) | Returns the number with the highest value |\n| min(x, y, z, ..., n) | Returns the number with the lowest value |\n| pow(x, y) | Returns the value of x to the power of y |\n| random() | Returns a random number between 0 and 1 |\n| round(x) | Rounds x to the nearest integer |\n| sign(x) | Returns if x is negative, null or positive (-1, 0, 1) |\n| sin(x) | Returns the sine of x (x is in radians) |\n| sinh(x) | Returns the hyperbolic sine of x |\n| sqrt(x) | Returns the square root of x |\n| tan(x) | Returns the tangent of an angle |\n| tanh(x) | Returns the hyperbolic tangent of a number |\n| trunc(x) | Returns the integer part of a number (x) |\n\n## Sets\n\nA Set is a collection of unique values. A Set can hold any datatype, including primitive types and objects.\n\n```javascript\nconst letters = new Set([\"a\",\"b\",\"c\"]);\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### Set Properties\n\n**constructor** - Returns the function that created the Set object's prototype\n\n```javascript\nletters.constructor; // ƒ Set() { [native code] }\n```\n\n**prototype** - Allows you to add properties and methods to a Set object\n\n```javascript\nSet.prototype.size = 0;\n\nconst letters = new Set([\"a\",\"b\",\"c\"]);\nletters.size; // 3\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### Set Methods\n\nThe Set object has several built-in methods that can be used to work with Sets. Some of the most commonly used methods are:\n\n- new Set()\n- add()\n- delete()\n- has()\n- forEach()\n- values()\n- size\n\n**new Set** - Creates a new Set\n\n```javascript\nconst letters = new Set([\"a\",\"b\",\"c\"]);\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**add** - Adds a new element to the Set\n\n```javascript\nletters.add(\"d\");\n```\n\n**delete** - Removes an element from a Set\n\n```javascript\nletters.delete(\"d\");\n```\n\n**has** - Returns true if a value exists in the Set\n\n```javascript\nletters.has(\"a\");\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**forEach** - Invokes a callback for each element in the Set\n\n```javascript\n// Create a Set\nconst letters = new Set([\"a\", \"b\", \"c\"]);\n\n// List all Elements\nlet text = \"\";\nletters.forEach(function(value) {\n  text += value + \" \";\n});\n\nconsole.log(text.trim()); // Output: \"a b c\"\n```\n\n**values** - Returns an iterator with all the values in a Set\n\n```javascript\nletters.values()   // Returns [object Set Iterator]\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**size Property** - Returns the number of elements in a Set\n\n```javascript\nletters.size;\n```\n\n## Map\n\nA Map holds key-value pairs where the keys can be any datatype. A Map remembers the original insertion order of the keys.\n\n```javascript\nconst fruits = new Map([\n  [\"apples\", 500],\n  [\"bananas\", 300],\n  [\"oranges\", 200]\n]);\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### Map Properties\n\n**constructor** - Returns the function that created the Map object's prototype\n\n```javascript\nfruits.constructor; // ƒ Map() { [native code] }\n```\n\n**prototype** - Allows you to add properties and methods to a Map object\n\n```javascript\nMap.prototype.size = 0;\n\nconst fruits = new Map([\n  [\"apples\", 500],\n  [\"bananas\", 300],\n  [\"oranges\", 200]\n]);\nfruits.size; // 3\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### Map Methods\n\nThe Map object has several built-in methods that can be used to work with Maps. Some of the most commonly used methods are:\n\n- new Map()\n- set()\n- get()\n- delete()\n- has()\n- forEach()\n- entries()\n- size\n\n**new Map** - Creates a new Map\n\n```javascript\n// Create a Map\nconst fruits = new Map([\n  [\"apples\", 500],\n  [\"bananas\", 300],\n  [\"oranges\", 200]\n]);\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**set** - Sets the value for a key in a Map\n\n```javascript\n// Create a Map\nconst fruits = new Map();\n\n// Set Map Values\nfruits.set(\"apples\", 500);\nfruits.set(\"bananas\", 300);\nfruits.set(\"oranges\", 200);\n```\n\n**get** - Gets the value for a key in a Map\n\n```javascript\nfruits.get(\"apples\");    // Returns 500\n```\n\n**delete** - Removes a Map element specified by the key\n\n```javascript\nfruits.delete(\"apples\");\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**has** - Returns true if a key exists in a Map\n\n```javascript\nfruits.has(\"apples\");\n```\n\n**forEach** - Calls a function for each key/value pair in a Map\n\n```javascript\n// List all entries\nlet text = \"\";\nfruits.forEach (function(value, key) {\n  text += key + ' = ' + value;\n})\n```\n\n**entries** - Returns an iterator with the [key, value] pairs in a Map.\n\n```javascript\n// List all entries\nlet text = \"\";\nfor (const x of fruits.entries()) {\n  text += x;\n}\n```\n\n**size Property** - Returns the number of elements in a Map\n\n```javascript\nfruits.size;\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Recursion\n\nRecursion is a programming technique where a function calls itself in order to solve a problem. Recursion is used to solve problems that can be broken down into smaller, more manageable subproblems.\n\n```javascript\nfunction factorial(n) {\n  if (n === 0) {\n    return 1;\n  } else {\n    return n * factorial(n - 1);\n  }\n}\n\nfactorial(5); // 120\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Async\n\nAsynchronous programming allows you to run multiple tasks concurrently without blocking the main thread. JavaScript provides several ways to work with asynchronous code, including callbacks, promises, and async/await.\n\n### Callbacks\n\nA callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.\n\n```javascript\nfunction myDisplayer(some) {\n  document.getElementById(\"demo\").innerHTML = some;\n}\n\nfunction myCalculator(num1, num2, myCallback) {\n  let sum = num1 + num2;\n  myCallback(sum);\n}\n\nmyCalculator(5, 5, myDisplayer);\n\n// Output: 10\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### Asynchronous JavaScript\n\nJavaScript is a single-threaded language, which means it can only execute one task at a time. Asynchronous JavaScript allows you to run multiple tasks concurrently without blocking the main thread.\n\n```javascript\nlet myPromise = new Promise((resolve, reject) =\u003e {\n  setTimeout(() =\u003e {\n    resolve(\"The async operation was successful\");\n  }, 1000);\n});\n\nmyPromise.then((value) =\u003e {\n  console.log(value);\n});\n\n// Output: The async operation was successful\n```\n\n### Promise\n\nA promise is an object that represents the eventual completion (or failure) of an asynchronous operation and its resulting value.\n\nSyntax -\n\n```javascript\nconst myPromise = new Promise((resolve, reject) =\u003e {\n    // code\n});\n\nmyPromise.then(\n    (value) =\u003e {\n        // success\n    },\n    (error) =\u003e {\n        // error\n    }\n);\n\nmyPromise.catch(\n    (error) =\u003e {\n        // error\n    }\n);\n\nmyPromise.finally(\n    () =\u003e {\n        // code\n    }\n);\n\nmyPromise.all([promise1, promise2, promise3, ...])\n```\n\nExample\n\n```javascript\nconst myPromise = new Promise((resolve, reject) =\u003e {\n    setTimeout(() =\u003e {\n        resolve(\"The async operation was successful\");\n    }, 1000);\n});\n\nmyPromise.then((value) =\u003e {\n    console.log(value);\n});\n\n// Output: The async operation was successful\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### async/await\n\nThe async/await syntax allows you to write asynchronous code that looks synchronous. The async keyword is used to define an asynchronous function, and the await keyword is used to wait for a promise to be resolved.\n\nAsync Syntax\n\n```javascript\nasync function myFunction() {\n    // code\n}\n```\n\nAwait Syntax\n\n```javascript\nlet result = await promise;\n\n// or\n\nawait promise;\n```\n\nExample\n\n```javascript\nasync function myFunction() {\n    let promise = new Promise((resolve, reject) =\u003e {\n        setTimeout(() =\u003e resolve(\"The async operation was successful\"), 1000);\n    });\n\n    let result = await promise;\n    console.log(result);\n}\n\nmyFunction();\n\n// Output: The async operation was successful\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## DOM\n\nThe Document Object Model (DOM) is a programming interface for web documents. It represents the structure of a document as a tree of nodes, where each node is an object representing a part of the document.\n\n### DOM Properties\n\n**document.body** - Returns the body element\n\n```javascript\ndocument.body;\n```\n\n**document.cookie** - Returns the document's cookie\n\n```javascript\ndocument.cookie;\n```\n\n**document.doctype** - Returns the document's doctype\n\n```javascript\ndocument.doctype;\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**document.documentElement** - Returns the document's root element\n\n```javascript\ndocument.documentElement;\n```\n\n**document.documentURI** - Returns the URI of the document\n\n```javascript\ndocument.documentURI;\n```\n\n**document.domain** - Returns the domain name of the server that loaded the document\n\n```javascript\ndocument.domain;\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**document.head** - Returns the head element\n\n```javascript\ndocument.head;\n```\n\n**document.images** - Returns a collection of all images in the document\n\n```javascript\ndocument.images;\n```\n\n**document.lastModified** - Returns the date and time the document was last modified\n\n```javascript\ndocument.lastModified;\n```\n\n**document.links** - Returns a collection of all links in the document\n\n```javascript\ndocument.links;\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**document.readyState** - Returns the loading status of the document\n\n```javascript\ndocument.readyState;\n```\n\n**document.referrer** - Returns the URI of the referrer (the linking document)\n\n```javascript\ndocument.referrer;\n```\n\n**document.title** - Returns the title of the document\n\n```javascript\ndocument.title;\n```\n\n**document.URL** - Returns the complete URL of the document\n\n```javascript\ndocument.URL;\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### DOM Methods\n\nThe Document object has several built-in methods that can be used to manipulate the document. Some of the most commonly used methods are:\n\naddEventListener() - It is used to add an event listener to the document.\n\n```javascript\ndocument.addEventListener(\"click\", () =\u003e {\n  console.log(\"The document was clicked\");\n});\n```\n\nadoptNode() - It is used to adopt the node from the other documents.\n\n```javascript\ndocument.adoptNode(node);\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nappend() - It appends the new node or HTML after the last child node of the document.\n\n```javascript\ndocument.append(node);\n```\n\ncaretPositionFromPoint() - It returns the caretPosition object, containing the DOM node based on the coordinates passed as an argument.\n\n```javascript\ndocument.caretPositionFromPoint(x, y);\n```\n\nclose() - It closes the output stream opened using the document.open() method.\n\n```javascript\ndocument.close();\n```\n\n[Back to Top⤴️](#table-of-contents)\n\ncreateAttribute() - It creates a new attribute node.\n\n```javascript\ndocument.createAttribute(\"class\");\n```\n\ncreateAttributeNS() - It creates a new attribute node with the particular namespace URI.\n\n```javascript\ndocument.createAttributeNS(\"http://www.w3.org/2000/svg\", \"class\");\n```\n\ncreateComment() - It creates a new comment node with a specific text message.\n\n```javascript\ndocument.createComment(\"This is a comment\");\n```\n\n[Back to Top⤴️](#table-of-contents)\n\ncreateDocumentFragment() - It creates a DocumentFragment node.\n\n```javascript\ndocument.createDocumentFragment();\n```\n\ncreateElement() - It creates a new element node to insert into the web page.\n\n```javascript\ndocument.createElement(\"div\");\n```\n\ncreateElementNS() - It is used to create a new element node with a particular namespace URI.\n\n```javascript\ndocument.createElementNS(\"http://www.w3.org/2000/svg\", \"div\");\n```\n\ncreateEvent() - It creates a new event node.\n\n```javascript\ndocument.createEvent(\"Event\");\n```\n\n[Back to Top⤴️](#table-of-contents)\n\ncreateTextNode() - It creates a new text node.\n\n```javascript\ndocument.createTextNode(\"This is a text node\");\n```\n\nelementFromPoint() - It accesses the element from the specified coordinates.\n\n```javascript\ndocument.elementFromPoint(x, y);\n```\n\nelementsFromPoint() - It returns the array of elements that are at the specified coordinates.\n\n```javascript\ndocument.elementsFromPoint(x, y);\n```\n\n[Back to Top⤴️](#table-of-contents)\n\ngetAnimations() - It returns the array of all animations applied on the document.\n\n```javascript\ndocument.getAnimations();\n```\n\ngetElementById() - It accesses the HTML element using the id.\n\n```javascript\ndocument.getElementById(\"id\");\n```\n\ngetElementsByClassName() - It accesses the HTML element using the class name.\n\n```javascript\ndocument.getElementsByClassName(\"class\");\n```\n\n[Back to Top⤴️](#table-of-contents)\n\ngetElementsByName() - It accesses the HTML element using the name.\n\n```javascript\ndocument.getElementsByName(\"name\");\n```\n\ngetElementsByTagName() - It accesses the HTML element using the tag name.\n\n```javascript\ndocument.getElementsByTagName(\"tag\");\n```\n\nhasFocus() - It returns the boolean value based on whether any element or document itself is in the focus.\n\n```javascript\ndocument.hasFocus();\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nimportNode() - It is used to import the node from another document.\n\n```javascript\ndocument.importNode(node);\n```\n\nnormalize() - It removes the text nodes, which are empty, and joins other nodes.\n\n```javascript\ndocument.normalize();\n```\n\nopen() - It is used to open a new output stream.\n\n```javascript\ndocument.open();\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nprepand() - It is used to insert the particular node before all nodes.\n\n```javascript\ndocument.prepand(node);\n```\n\nquerySelector() - It is used to select the first element that matches the css selector passed as an argument.\n\n```javascript\ndocument.querySelector(\"p\");\n```\n\nquerySelectorAll() - It returns the nodelist of the HTML elements, which matches the multiple CSS selectors.\n\n```javascript\ndocument.querySelectorAll(\"p.intro\");\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nremoveEventListener() - It is used to remove the event listener from the document.\n\n```javascript\ndocument.removeEventListener(\"click\", () =\u003e {\n  console.log(\"The document was clicked\");\n});\n```\n\nreplaceChildren() - It replaces the children nodes of the document.\n\n```javascript\ndocument.replaceChildren(node);\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nwrite() - It is used to write text, HTML, etc., into the document.\n\n```javascript\ndocument.write(\"Hello World!\");\n```\n\nwriteln() - It is similar to the write() method but writes each statement in the new line.\n\n```javascript\ndocument.writeln(\"Hello World!\");\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n### Documents\n\nThe Document object represents the entire HTML document. It is the root node of the HTML document tree.\n\n**Finding HTML Elements** -\n\n| Method | Description |\n|---|---|\n| document.getElementById(id) | Find an element by element id |\n| document.getElementsByTagName(name) | Find elements by tag name |\n| document.getElementsByClassName(name) | Find elements by class name |\n\n**Changing HTML Elements** -\n\n| Property | Description |\n|--|--|\n| element.innerHTML =  new html content | Change the inner HTML of an element |\n| element.attribute = new value | Change the attribute value of an HTML element |\n| element.style.property = new style | Change the style of an HTML element |\n\n| Method | Description |\n|--|--|\n| element.setAttribute(attribute, value) | Change the attribute value of an HTML element |\n\n[Back to Top⤴️](#table-of-contents)\n\n**Adding and Deleting Elements** -\n\n| Method | Description |\n|--|--|\n| document.createElement(element) | Create an HTML element |\n| document.removeChild(element) | Remove an HTML element |\n| document.appendChild(element) | Add an HTML element |\n| document.replaceChild(new, old) | Replace an HTML element |\n| document.write(text) | Write into the HTML output stream |\n\n**Adding Events Handlers** -\n\n| Method | Description |\n|--|--|\n| document.getElementById(id).onclick = function(){code} | Adding event handler code to an onclick event |\n\n**Finding HTML Objects** -\n\n| Property | Description | DOM |\n|--|--|--|\n| document.anchors | Returns all elements that have a name attribute | 1 |\n| document.applets | Deprecated | 1 |\n| document.baseURI | Returns the absolute base URI of the document | 3 |\n| document.body | Returns the element | 1 |\n| document.cookie | Returns the document's cookie | 1 |\n| document.doctype | Returns the document's doctype | 3 |\n| document.documentElement | Returns the element | 3 |\n| document.documentMode | Returns the mode used by the browser | 3 |\n| document.documentURI | Returns the URI of the document | 3 |\n| document.domain | Returns the domain name of the document server | 1 |\n| document.domConfig | Obsolete. | 3 |\n| document.embeds | Returns all  elements | 3 |\n| document.forms | Returns all  elements | 1 |\n| document.head | Returns the  element | 3 |\n| document.images | Returns all  elements | 1 |\n| document.implementation | Returns the DOM implementation | 3 |\n| document.inputEncoding | Returns the document's encoding (character set) | 3 |\n| document.lastModified | Returns the date and time the document was updated | 3 |\n| document.links | Returns all  and elements that have a href attribute | 1 |\n| document.readyState | Returns the (loading) status of the document | 3 |\n| document.referrer | Returns the URI of the referrer (the linking document) | 1 |\n| document.scripts | Returns all  elements | 3 |\n| document.strictErrorChecking | Returns if error checking is enforced | 3 |\n| document.title | Returns the  element | 1 |\n| document.URL | Returns the complete URL of the document | 1 |\n\n[Back to Top⤴️](#table-of-contents)\n\n**Elements** -\n\nFinding HTML elements by id\n\n```javascript\nconst element = document.getElementById(\"intro\");\n```\n\nFinding HTML elements by tag name\n\n```javascript\nconst element = document.getElementsByTagName(\"p\");\n```\n\nFinding HTML elements by class name\n\n```javascript\nconst x = document.getElementsByClassName(\"intro\");\n```\n\nFinding HTML elements by CSS selectors\n\n```javascript\nconst x = document.querySelectorAll(\"p.intro\");\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nFinding HTML elements by HTML object collections\n\n```javascript\nconst x = document.forms[\"frm1\"];\nlet text = \"\";\nfor (let i = 0; i \u003c x.length; i++) {\n  text += x.elements[i].value + \"\u003cbr\u003e\";\n}\ndocument.getElementById(\"demo\").innerHTML = text;\n```\n\nChanging HTML\n\n```javascript\ndocument.getElementById(\"demo\").innerHTML = \"Hello World!\";\n```\n\nForms\n\n```javascript\ndocument.getElementById(\"myForm\").submit();\n```\n\nChanging CSS\n\n```javascript\ndocument.getElementById(\"demo\").style.fontSize = \"35px\";\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nAnimations\n\n```javascript\ndocument.getElementById(\"animate\").style.animation = \"mymove 4s infinite\";\n```\n\nEvents\n\n```javascript\ndocument.getElementById(\"myBtn\").addEventListener(\"click\", displayDate);\n```\n\nEvent Listener\n\n```javascript\ndocument.getElementById(\"myBtn\").addEventListener(\"click\", function() {\n  alert(\"Hello World!\");\n});\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nNavigation\n\n```javascript\ndocument.getElementById(\"myAnchor\").href = \"https://www.w3schools.com\";\n```\n\nNodes\n\n```javascript\ndocument.getElementById(\"demo\").childNodes[0].nodeValue = \"new text\";\n```\n\nCollections\n\n```javascript\ndocument.getElementsByTagName(\"p\");\n```\n\nNode\n\n```javascript\ndocument.getElementById(\"main\").firstChild.nodeValue;\n```\n\nLists\n\n```javascript\ndocument.getElementById(\"myList\").innerHTML = \"Mango\";\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Browser BOM\n\nBrowser Object Model (BOM) is used to interact with the browser. The Browser Object Model (BOM) allows JavaScript to interact with the browser. The BOM is not standardized, and its properties and methods may differ between browsers.\n\n**Window** -\n\nWindow Object\n\n```javascript\nwindow.document.getElementById(\"header\");\n//or\ndocument.getElementById(\"header\");\n```\n\nWindow Size\n\nwindow.innerHeight - the inner height of the browser window (in pixels)\n\nwindow.innerWidth - the inner width of the browser window (in pixels)\n\nwindow.open() - open a new window\n\nwindow.close() - close the current window\n\nwindow.moveTo() - move the current window\n\nwindow.resizeTo() - resize the current window\n\n```javascript\nwindow.innerWidth;\n\nwindow.innerHeight;\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**Window Screen** -\n\n`window.screen` - object contains information about the user's screen.\n\nscreen.width\n\n```javascript\ndocument.getElementById(\"demo\").innerHTML =\n\"Screen Width: \" + screen.width;\n```\n\nscreen.height\n\n```javascript\ndocument.getElementById(\"demo\").innerHTML =\n\"Screen Height: \" + screen.height;\n```\n\nscreen.availWidth\n\n```javascript\ndocument.getElementById(\"demo\").innerHTML =\n\"Available Screen Width: \" + screen.availWidth;\n```\n\nscreen.availHeight\n\n```javascript\ndocument.getElementById(\"demo\").innerHTML =\n\"Available Screen Height: \" + screen.availHeight;\n```\n\nscreen.colorDepth\n\n```javascript\ndocument.getElementById(\"demo\").innerHTML =\n\"Screen Color Depth: \" + screen.colorDepth;\n```\n\nscreen.pixelDepth\n\n```javascript\ndocument.getElementById(\"demo\").innerHTML =\n\"Screen Pixel Depth: \" + screen.pixelDepth;\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nExample\n\n```javascript\ndocument.getElementById('demo1').innerHTML = 'Screen Width: ' + screen.width;\ndocument.getElementById('demo2').innerHTML = 'Screen Height: ' + screen.height;\ndocument.getElementById('demo3').innerHTML =\n  'Available Screen Width: ' + screen.availWidth;\ndocument.getElementById('demo4').innerHTML =\n  'Available Screen Height: ' + screen.availHeight;\ndocument.getElementById('demo5').innerHTML =\n  'Screen Color Depth: ' + screen.colorDepth;\ndocument.getElementById('demo6').innerHTML =\n  'Screen Pixel Depth: ' + screen.pixelDepth;\n```\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eWindow Screen\u003c/title\u003e\n    \u003cmeta charset=\"UTF-8\" /\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width\" /\u003e\n    \u003clink rel=\"stylesheet\" href=\"styles.css\" /\u003e\n    \u003cscript type=\"module\" src=\"script.js\"\u003e\u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cmain\u003e\n      \u003cp id=\"demo1\"\u003e\u003c/p\u003e\n      \u003cp id=\"demo2\"\u003e\u003c/p\u003e\n      \u003cp id=\"demo3\"\u003e\u003c/p\u003e\n      \u003cp id=\"demo4\"\u003e\u003c/p\u003e\n      \u003cp id=\"demo5\"\u003e\u003c/p\u003e\n      \u003cp id=\"demo6\"\u003e\u003c/p\u003e\n    \u003c/main\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n[Stackblitz Link](https://stackblitz.com/edit/web-platform-paqevc?file=index.html)\n\n[Back to Top⤴️](#table-of-contents)\n\nWindow Location\n\n`window.location` - object can be used to get the current page address (URL) and to redirect the browser to a new page.\n\nwindow.location.href returns the href (URL) of the current page\n\n```javascript\ndocument.getElementById(\"demo\").innerHTML =\n\"Page location is \" + window.location.href;\n```\n\nwindow.location.hostname returns the domain name of the web host\n\n```javascript\ndocument.getElementById(\"demo\").innerHTML =\n\"Page hostname is \" + window.location.hostname;\n```\n\nwindow.location.pathname returns the path and filename of the current page\n\n```javascript\ndocument.getElementById(\"demo\").innerHTML =\n\"Page path is \" + window.location.pathname;\n```\n\nwindow.location.protocol returns the web protocol used (http: or https:)\n\n```javascript\ndocument.getElementById(\"demo\").innerHTML =\n\"Page protocol is \" + window.location.protocol;\n```\n\nwindow.location.assign() loads a new document\n\n```javascript\ndocument.getElementById(\"demo\").innerHTML =\n\"Port number is \" + window.location.port;\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nWindow Location Assign\n\n```javascript\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003cbody\u003e\n\n\u003ch2\u003eJavaScript\u003c/h2\u003e\n\n\u003ch3\u003eThe window.location object\u003c/h3\u003e\n\n\u003cinput type=\"button\" value=\"Load new document\" onclick=\"newDoc()\"\u003e\n\n\u003cscript\u003e\nfunction newDoc() {\n  window.location.assign(\"https://www.w3schools.com\")\n}\n\u003c/script\u003e\n\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\nExample\n\n```javascript\ndocument.getElementById('demo1').innerHTML =\n  'Page location is ' + window.location.href;\ndocument.getElementById('demo2').innerHTML =\n  'Page hostname is ' + window.location.hostname;\ndocument.getElementById('demo3').innerHTML =\n  'Page path is ' + window.location.pathname;\ndocument.getElementById('demo4').innerHTML =\n  'Page protocol is ' + window.location.protocol;\ndocument.getElementById('demo5').innerHTML =\n  'Port number is ' + window.location.port;\n```\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eWindow Location\u003c/title\u003e\n    \u003cmeta charset=\"UTF-8\" /\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width\" /\u003e\n    \u003clink rel=\"stylesheet\" href=\"styles.css\" /\u003e\n    \u003cscript type=\"module\" src=\"script.js\"\u003e\u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cnav\u003e\n      \u003ch1\u003eWindow Location Example\u003c/h1\u003e\n    \u003c/nav\u003e\n    \u003cmain\u003e\n      \u003cp id=\"demo1\"\u003e\u003c/p\u003e\n      \u003cp id=\"demo2\"\u003e\u003c/p\u003e\n      \u003cp id=\"demo3\"\u003e\u003c/p\u003e\n      \u003cp id=\"demo4\"\u003e\u003c/p\u003e\n      \u003cp id=\"demo5\"\u003e\u003c/p\u003e\n    \u003c/main\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n[Stackblitz Link](https://stackblitz.com/edit/web-platform-sixdd6?file=script.js)\n\n[Back to Top⤴️](#table-of-contents)\n\n**Window History** - The window.history object contains the browser's history.\n\n`window.history` - object can be written without the window prefix.\n\nhistory.back() - same as clicking back in the browser\n\nhistory.forward() - same as clicking forward in the browser\n\n```javascript\nwindow.history.back()\nwindow.history.forward()\n```\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eWindow History\u003c/title\u003e\n    \u003cmeta charset=\"UTF-8\" /\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width\" /\u003e\n    \u003clink rel=\"stylesheet\" href=\"styles.css\" /\u003e\n    \u003cscript type=\"module\" src=\"script.js\"\u003e\u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cnav\u003e\n      \u003ch1\u003eWindow History\u003c/h1\u003e\n    \u003c/nav\u003e\n    \u003cmain\u003e\n      \u003cinput type=\"button\" value=\"Forward\" onclick=\"goForward()\" /\u003e\n      \u003cinput type=\"button\" value=\"Back\" onclick=\"goBack()\" /\u003e\n    \u003c/main\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**Window Navigator** - Window Navigator object contains information about the visitor's browser.\n\nnavigator.cookieEnabled\n\nnavigator.appCodeName\n\nnavigator.platform\n\nBrowser Cookies\n\n```javascript\ndocument.getElementById(\"demo\").innerHTML =\n\"cookiesEnabled is \" + navigator.cookieEnabled;\n```\n\nBrowser Application Name\n\n```javascript\ndocument.getElementById(\"demo\").innerHTML =\n\"navigator.appName is \" + navigator.appName;\n```\n\nBrowser Application Code Name\n\n```javascript\ndocument.getElementById(\"demo\").innerHTML =\n\"navigator.appCodeName is \" + navigator.appCodeName;\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nBrowser Engine\n\n```javascript\ndocument.getElementById(\"demo\").innerHTML =\n\"navigator.product is \" + navigator.product;\n```\n\nBrowser Version\n\n```javascript\ndocument.getElementById(\"demo\").innerHTML = navigator.appVersion;\n```\n\nBrowser Agent\n\n```javascript\ndocument.getElementById(\"demo\").innerHTML = navigator.userAgent;\n```\n\nBrowser Platform\n\n```javascript\ndocument.getElementById(\"demo\").innerHTML = navigator.platform;\n```\n\nBrowser Language\n\n```javascript\ndocument.getElementById(\"demo\").innerHTML = navigator.language;\n```\n\nIs The Browser Online?\n\n```javascript\ndocument.getElementById(\"demo\").innerHTML = navigator.onLine;\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nIs Java Enabled?\n\n```javascript\ndocument.getElementById(\"demo\").innerHTML = navigator.javaEnabled();\n```\n\n```javascript\ndocument.getElementById('demo1').innerHTML =\n  'navigator.cookieEnabled is ' + navigator.cookieEnabled;\ndocument.getElementById('demo2').innerHTML =\n  'navigator.appName is ' + navigator.appName;\ndocument.getElementById('demo3').innerHTML =\n  'navigator.appCodeName is ' + navigator.appCodeName;\ndocument.getElementById('demo4').innerHTML =\n  'navigator.product is ' + navigator.product;\ndocument.getElementById('demo5').innerHTML =\n  'navigator.appVersion is ' + navigator.appVersion;\ndocument.getElementById('demo6').innerHTML =\n  'navigator.userAgent is ' + navigator.userAgent;\ndocument.getElementById('demo7').innerHTML =\n  'navigator.platform is ' + navigator.platform;\ndocument.getElementById('demo8').innerHTML =\n  'navigator.language is ' + navigator.language;\ndocument.getElementById('demo9').innerHTML =\n  'navigator.onLine is ' + navigator.onLine;\ndocument.getElementById('demo10').innerHTML =\n  'navigator.javaEnabled is ' + navigator.javaEnabled();\n```\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eWindow Navigator\u003c/title\u003e\n    \u003cmeta charset=\"UTF-8\" /\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width\" /\u003e\n    \u003clink rel=\"stylesheet\" href=\"styles.css\" /\u003e\n    \u003cscript type=\"module\" src=\"script.js\"\u003e\u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cnav\u003e\n      \u003ch1\u003eWindow Navigator\u003c/h1\u003e\n    \u003c/nav\u003e\n    \u003cmain\u003e\n      \u003cp id=\"demo1\"\u003e\u003c/p\u003e\n      \u003cp id=\"demo2\"\u003e\u003c/p\u003e\n      \u003cp id=\"demo3\"\u003e\u003c/p\u003e\n      \u003cp id=\"demo4\"\u003e\u003c/p\u003e\n      \u003cp id=\"demo5\"\u003e\u003c/p\u003e\n      \u003cp id=\"demo6\"\u003e\u003c/p\u003e\n      \u003cp id=\"demo7\"\u003e\u003c/p\u003e\n      \u003cp id=\"demo8\"\u003e\u003c/p\u003e\n      \u003cp id=\"demo9\"\u003e\u003c/p\u003e\n      \u003cp id=\"demo10\"\u003e\u003c/p\u003e\n    \u003c/main\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n[Stackblitz Link](https://stackblitz.com/edit/web-platform-m1vzbh?file=index.html)\n\n[Back to Top⤴️](#table-of-contents)\n\n**Popup Boxes** -\n\nAlert Box\n\n`window.alert(\"sometext\");`\n\n```javascript\nfunction myFunction() {\n  alert('I am an alert box!');\n}\n```\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eAlert Box\u003c/title\u003e\n    \u003cmeta charset=\"UTF-8\" /\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width\" /\u003e\n    \u003clink rel=\"stylesheet\" href=\"styles.css\" /\u003e\n    \u003cscript type=\"module\" src=\"script.js\"\u003e\u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cnav\u003e\n      \u003ch2\u003eAlert Box\u003c/h2\u003e\n    \u003c/nav\u003e\n    \u003cmain\u003e\n      \u003cbutton onclick=\"myFunction()\"\u003eTry it\u003c/button\u003e\n    \u003c/main\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n[Replit Link](https://replit.com/@manthanank/Alert-box-in-JavaScript#index.html)\n\n[Back to Top⤴️](#table-of-contents)\n\nConfirm Box\n\n`window.confirm(\"sometext\");`\n\n```javascript\nfunction myFunction() {\n  var txt;\n  if (confirm(\"Press a button!\")) {\n    txt = \"You pressed OK!\";\n  } else {\n    txt = \"You pressed Cancel!\";\n  }\n  document.getElementById(\"demo\").innerHTML = txt;\n}\n```\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eConfirm Box\u003c/title\u003e\n    \u003cmeta charset=\"UTF-8\" /\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width\" /\u003e\n    \u003clink rel=\"stylesheet\" href=\"styles.css\" /\u003e\n    \u003cscript type=\"module\" src=\"script.js\"\u003e\u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cnav\u003e\n      \u003ch1\u003eConfirm Box\u003c/h1\u003e\n    \u003c/nav\u003e\n    \u003cmain\u003e\n      \u003cbutton onclick=\"myFunction()\"\u003eTry it\u003c/button\u003e\n      \u003cp id=\"demo\"\u003e\u003c/p\u003e\n    \u003c/main\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n[Replit Link](https://replit.com/@manthanank/Confirm-Box-in-JavaScript#index.html)\n\n[Back to Top⤴️](#table-of-contents)\n\nPrompt Box\n\n`window.prompt(\"sometext\",\"defaultText\");`\n\n```javascript\nfunction myFunction() {\n  let text;\n  let person = prompt('Please enter your name:', 'Harry Potter');\n  if (person == null || person == '') {\n    text = 'User cancelled the prompt.';\n  } else {\n    text = 'Hello ' + person + '! How are you today?';\n  }\n  document.getElementById('demo').innerHTML = text;\n}\n```\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eHome\u003c/title\u003e\n    \u003cmeta charset=\"UTF-8\" /\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width\" /\u003e\n    \u003clink rel=\"stylesheet\" href=\"styles.css\" /\u003e\n    \u003cscript type=\"module\" src=\"script.js\"\u003e\u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cnav\u003e\n      \u003ch1\u003ePrompt Box\u003c/h1\u003e\n    \u003c/nav\u003e\n    \u003cmain\u003e\n      \u003cbutton onclick=\"myFunction()\"\u003eTry it\u003c/button\u003e\n\n      \u003cp id=\"demo\"\u003e\u003c/p\u003e\n    \u003c/main\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n[Replit Link](https://replit.com/@manthanank/Prompt-Box#index.html)\n\n[Back to Top⤴️](#table-of-contents)\n\nLine Breaks\n\n```javascript\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eHome\u003c/title\u003e\n    \u003cmeta charset=\"UTF-8\" /\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width\" /\u003e\n    \u003clink rel=\"stylesheet\" href=\"styles.css\" /\u003e\n    \u003cscript type=\"module\" src=\"script.js\"\u003e\u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cnav\u003e\n      \u003ch1\u003eLine Breaks\u003c/h1\u003e\n    \u003c/nav\u003e\n    \u003cmain\u003e\n      \u003cbutton onclick=\"alert('Hello\\nHow are you?')\"\u003eTry it\u003c/button\u003e\n    \u003c/main\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n[Replit Link](https://replit.com/@manthanank/Line-Breaks-in-JavaScript#index.html)\n\n[Back to Top⤴️](#table-of-contents)\n\n**Timing Events** -\n\n**setTimeout(function, milliseconds)** - Executes a function, after waiting a specified number of milliseconds.\n\nSyntax : `window.setTimeout(function, milliseconds);`\n\n```javascript\nsetTimeout(() =\u003e {\n  console.log(\"Hello World!\");\n}, 5000);\n```\n\n**setInterval(function, milliseconds)** - Same as setTimeout(), but repeats the execution of the function continuously.\n\nSyntax : `window.setInterval(function, milliseconds);`\n\n```javascript\nsetInterval(() =\u003e {\n  console.log(\"Hello World!\");\n}, 5000);\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**Cookies** - Cookies are data, stored in small text files, on your computer.\n\nCreate a Cookie with JavaScript\n\n```javascript\ndocument.cookie = \"username=Manthan Ank\";\n\n//with an expiry date(in UTC Time)\ndocument.cookie = \"username=Manthan Ank; expires=Sat, 28 Jan 2023 12:00:00 UTC\";\n\n//with path parameter\ndocument.cookie = \"username=Manthan Ank; expires=Sat, 28 Jan 2023 12:00:00 UTC; path=/\";\n```\n\nRead a Cookie with JavaScript\n\n```javascript\nlet x = document.cookie;\nconsole.log(x);\n```\n\nChange a Cookie with JavaScript\n\n```javascript\ndocument.cookie = \"username=Manthan Ankolekar; expires=Sat, 28 Jan 2023 12:00:00 UTC; path=/\";\n```\n\nDelete a Cookie with JavaScript\n\n```javascript\ndocument.cookie = \"username=; expires=Sat, 28 Jan 2023 12:00:00 UTC; path=/;\";\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Web API\n\nWeb API is an application programming interface for the Web. It defines the structure of web services and allows different software applications to communicate with each other over the web.\n\n`API` - Application Programming Interface.\n\n**Forms API** -\n\n**Constraint Validation DOM Methods** -\n\n`checkValidity()` - Returns true if an input element contains valid data.\n\n```html\n\u003cinput id=\"id1\" type=\"number\" min=\"100\" max=\"300\" required\u003e\n\u003cbutton onclick=\"myFunction()\"\u003eOK\u003c/button\u003e\n\n\u003cp id=\"demo\"\u003e\u003c/p\u003e\n```\n\n```javascript\nfunction myFunction() {\n  const inpObj = document.getElementById(\"id1\");\n  if (!inpObj.checkValidity()) {\n    document.getElementById(\"demo\").innerHTML = inpObj.validationMessage;\n  }\n}\n```\n\n`setCustomValidity()` - Sets the validationMessage property of an input element.\n\n```javascript\ndocument.getElementById(\"id1\").setCustomValidity(\"Input not valid\");\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**Constraint Validation DOM Properties** -\n\n`validity` - Contains boolean properties related to the validity of an input element.\n\n```javascript\ndocument.getElementById(\"id1\").validity.rangeOverflow;\n```\n\n`validationMessage` - Contains the message a browser will display when the validity is false.\n\n```javascript\ndocument.getElementById(\"id1\").validationMessage;\n```\n\n`willValidate` - Indicates if an input element will be validated.\n\n```javascript\ndocument.getElementById(\"id1\").willValidate;\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**Validity Properties** -\n\n`customError` - Set to true, if a custom validity message is set.\n\n```javascript\ndocument.getElementById(\"id1\").validity.customError;\n```\n\n`patternMismatch` - Set to true, if an element's value does not match its pattern attribute.\n\n```javascript\ndocument.getElementById(\"id1\").validity.patternMismatch;\n```\n\n`rangeOverflow` - Set to true, if an element's value is greater than its max attribute.\n\n```html\n\u003cinput id=\"id1\" type=\"number\" max=\"100\"\u003e\n\u003cbutton onclick=\"myFunction()\"\u003eOK\u003c/button\u003e\n\n\u003cp id=\"demo\"\u003e\u003c/p\u003e\n```\n\n```jsx\nfunction myFunction() {\n  let text = \"Value OK\";\n  if (document.getElementById(\"id1\").validity.rangeOverflow) {\n    text = \"Value too large\";\n  }\n}\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n`rangeUnderflow` - Set to true, if an element's value is less than its min attribute.\n\n```html\n\u003cinput id=\"id1\" type=\"number\" max=\"100\"\u003e\n\u003cbutton onclick=\"myFunction()\"\u003eOK\u003c/button\u003e\n\n\u003cp id=\"demo\"\u003e\u003c/p\u003e\n```\n\n```jsx\nfunction myFunction() {\n  let text = \"Value OK\";\n  if (document.getElementById(\"id1\").validity.rangeUnderflow) {\n    text = \"Value too small\";\n  }\n}\n```\n\n`stepMismatch` - Set to true, if an element's value is invalid per its step attribute.\n\n```javascript\ndocument.getElementById(\"id1\").validity.stepMismatch;\n```\n\n`tooLong` - Set to true, if an element's value exceeds its maxLength attribute.\n\n```javascript\ndocument.getElementById(\"id1\").validity.tooLong;\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n`typeMismatch` - Set to true, if an element's value is invalid per its type attribute.\n\n```javascript\ndocument.getElementById(\"id1\").validity.typeMismatch;\n```\n\n`valueMissing` - Set to true, if an element (with a required attribute) has no value.\n\n```javascript\ndocument.getElementById(\"id1\").validity.valueMissing;\n```\n\n`valid` - Set to true, if an element's value is valid.\n\n```javascript\ndocument.getElementById(\"id1\").validity.valid;\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**History API** -\n\nWeb History API provides easy methods to access the windows.history object.\n\n`History back()` Method\n\n```javascript\nfunction myFunction() {\n  window.history.back();\n}\n```\n\n`History go()` Method\n\n```javascript\nfunction myFunction() {\n  window.history.go(-2);\n}\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**History Object Properties** -\n\n`length` - Returns the number of URLs in the history list\n\n```javascript\nhistory.length\n```\n\n**History Object Methods** -\n\n`back()` - Loads the previous URL in the history list\n\n```javascript\nhistory.back()\n```\n\n`forward()` - Loads the next URL in the history list\n\n```javascript\nhistory.forward()\n```\n\n`go()` - Loads a specific URL from the history list\n\n```javascript\nhistory.go()\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**Storage API** -\n\nWeb Storage API is a simple syntax for storing and retrieving data in the browser.\n\nThe localStorage Object -\n\nThe localStorage object provides access to a local storage for a particular Web Site. It allows you to store, read, add, modify, and delete data items for that domain.\n\nsetItem() Method\n\n```javascript\nlocalStorage.setItem(\"name\", \"Manthan Ankolekar\");\n```\n\ngetItem() Method\n\n```javascript\nlocalStorage.getItem(\"name\", \"Manthan Ankolekar\");\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nsessionStorage Object -\n\nThe sessionStorage object is identical to the localStorage object. The difference is that the sessionStorage object stores data for one session.\n\ngetItem() Method\n\n```javascript\nsessionStorage.getItem(\"name\");\n```\n\nsetItem() Method\n\n```javascript\nsessionStorage.setItem(\"name\", \"Manthan Ankolekar\");\n```\n\nStorage Object Properties and Methods\n\nkey(n) - Returns the name of the nth key in the storage\n\n```jsx\nlocalStorage.key(index)\nsessionStorage.key(index)\n```\n\nlength - Returns the number of data items stored in the Storage object\n\n```jsx\nlocalStorage.length;\nsessionStorage.length;\n```\n\n[Back to Top⤴️](#table-of-contents)\n\ngetItem(keyname) - Returns the value of the specified key name\n\n```jsx\nlocalStorage.getItem(keyname)\nsessionStorage.getItem(keyname)\n```\n\nsetItem(keyname, value) - Adds a key to the storage, or updates a key value (if it already exists)\n\n```jsx\nlocalStorage.setItem(keyname, value)\nsessionStorage.setItem(keyname, value)\n```\n\nremoveItem(keyname)- Removes that key from the storage\n\n```jsx\nlocalStorage.removeItem(keyname)\nsessionStorage.removeItem(keyname)\n```\n\nclear() - Empty all key out of the storage\n\n```jsx\nlocalStorage.clear()\nsessionStorage.clear()\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nRelated Pages for Web Storage API\n\nwindow.localStorage - Allows to save key/value pairs in a web browser. Stores the data with no expiration date\n\n```jsx\nwindow.localStorage\n\nlocalStorage\n```\n\nwindow.sessionStorage - Allows to save key/value pairs in a web browser. Stores the data for one session\n\n```jsx\nwindow.sessionStorage\n\nsessionStorage\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**Worker API** -\n\nA web worker is a JavaScript running in the background, without affecting the performance of the page.\n\n**Fetch API** -\n\nThe Fetch API interface allows web browser to make HTTP requests to web servers.\n\n```javascript\nfetch(file)\n.then(x =\u003e x.text())\n.then(y =\u003e myDisplay(y));\n```\n\n**GeoLocation API** -\n\nThe HTML Geolocation API is used to get the geographical position of a user.\n\n```javascript\nconst x = document.getElementById(\"demo\");\nfunction getLocation() {\n  if (navigator.geolocation) {\n    navigator.geolocation.getCurrentPosition(showPosition);\n  } else {\n    x.innerHTML = \"Geolocation is not supported by this browser.\";\n  }\n}\n\nfunction showPosition(position) {\n  x.innerHTML = \"Latitude: \" + position.coords.latitude +\n  \"\u003cbr\u003eLongitude: \" + position.coords.longitude;\n}\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## AJAX\n\nAJAX (Asynchronous JavaScript and XML) is a technique used in web development to create asynchronous web applications. It allows you to update parts of a web page without reloading the entire page. Originally, XML (eXtensible Markup Language) was commonly used for data exchange, but modern AJAX implementations often use JSON (JavaScript Object Notation) for data interchange due to its lighter syntax.\n\n**XMLHttp** - The XMLHttpRequest object is used to interact with servers asynchronously. Here's an example of creating an XMLHttpRequest object\n\n```javascript\nlet xhttp = new XMLHttpRequest();\n```\n\n**Request** - To make a request to a server, you'll typically use methods like open() and send()\n\n```javascript\nxhttp.open('GET', 'https://api.example.com/data', true); // Method, URL, async (true or false)\nxhttp.send(); // Send the request\n```\n\nYou can also send data along with the request by passing parameters within the send() method.\n\n[Back to Top⤴️](#table-of-contents)\n\n**Response** - Handling the response from the server can be done using event listeners like onreadystatechange and checking for the readyState and status of the request\n\n```javascript\nxhttp.onreadystatechange = function() {\n  if (this.readyState === 4 \u0026\u0026 this.status === 200) {\n    // Handle successful response\n    console.log(this.responseText); // Response data\n  } else {\n    // Handle errors\n    console.error('There was a problem with the request.');\n  }\n};\n```\n\n**XML File** - If you are working with an XML file, you can parse the response using methods like responseXML to access the XML data\n\n```javascript\nxhttp.onreadystatechange = function() {\n  if (this.readyState === 4 \u0026\u0026 this.status === 200) {\n    let xmlDoc = this.responseXML;\n    // Process xmlDoc for XML data\n    console.log(xmlDoc);\n  }\n};\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## JSON\n\nJSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. JSON is a text format that is completely language-independent but uses conventions that are familiar to programmers of the C family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others.\n\n### JSON Methods\n\nThere are two methods in JSON\n\n- `JSON.parse()`\n- `JSON.stringify()`\n\nparse() - Parses a JSON string and returns a JavaScript object\n\nstringify() - Convert a JavaScript object to a JSON string\n\nData Types\n\n- a string\n- a number\n- an object (containing valid JSON values)\n- an array\n- a boolean\n- null\n\n[Back to Top⤴️](#table-of-contents)\n\n**String:**\n\n```javascript\nconst str = \"Hello, World!\";\n```\n\n**Number:**\n\n```javascript\nconst num = 42;\n```\n\n**Object:**\n\n```javascript\nconst obj = {\n  name: \"John\",\n  age: 30,\n  city: \"New York\"\n};\n```\n\n**Array:**\n\n```javascript\nconst arr = [1, 2, 3, 4, 5];\n```\n\n**Boolean:**\n\n```javascript\nconst bool = true;\n```\n\n**Null:**\n\n```javascript\nconst nullValue = null;\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**Parse** - The parse() method is used to parse a JSON string and convert it into a JavaScript object.\n\n```javascript\nconst jsonString = '{\"name\": \"John\", \"age\": 30}';\nconst jsonObject = JSON.parse(jsonString);\nconsole.log(jsonObject); // Output: { name: 'John', age: 30 }\n```\n\n**Stringify** - The stringify() method is used to convert a JavaScript object into a JSON string.\n\n```javascript\nconst jsonObject = { name: 'John', age: 30 };\nconst jsonString = JSON.stringify(jsonObject);\nconsole.log(jsonString); // Output: '{\"name\":\"John\",\"age\":30}'\n```\n\n**Objects** - Objects in JSON are key-value pairs enclosed in curly braces {}.\n\n```javascript\nconst person = {\n  \"name\": \"Alice\",\n  \"age\": 30,\n  \"address\": {\n    \"city\": \"New York\",\n    \"zipcode\": \"10001\"\n  }\n};\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**Arrays** - Arrays in JSON are ordered lists of values enclosed in square brackets [].\n\n```javascript\nconst colors = [\"Red\", \"Green\", \"Blue\"];\n```\n\n## JQuery\n\njQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, and animation much simpler with an easy-to-use API that works across a multitude of browsers.\n\nSelectors\n\n```javascript\n$(\"p\")\n$(\".test\")\n$(\"#test\")\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Graphics\n\n**Canvas** - The HTML `\u003ccanvas\u003e` element is used to draw graphics, on the fly, via JavaScript.\n\n```javascript\nconst canvas = document.getElementById(\"myCanvas\");\nconst ctx = canvas.getContext(\"2d\");\nctx.fillStyle = \"#FF0000\";\nctx.fillRect(0, 0, 150, 75);\n```\n\n**Plotly** - Plotly is a charting library for JavaScript. It is used to create interactive charts in web applications.\n\n```javascript\nconst data = [\n  {\n    x: [1, 2, 3, 4, 5],\n    y: [1, 2, 4, 8, 16],\n    type: 'scatter'\n  }\n];\nPlotly.newPlot('myDiv', data);\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**Chart.js** - Chart.js is a simple yet flexible JavaScript charting library for designers \u0026 developers.\n\n```javascript\nconst ctx = document.getElementById('myChart').getContext('2d');\n```\n\n**Google Chart** - Google Charts provides a perfect way to visualize data on your website. From simple line charts to complex hierarchical tree maps, the chart gallery provides a large number of ready-to-use chart types.\n\n```javascript\ngoogle.charts.load('current', {packages: ['corechart', 'bar']});\ngoogle.charts.setOnLoadCallback(drawChart);\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n**D3.js** - D3.js is a JavaScript library for producing dynamic, interactive data visualizations in web browsers.\n\n```javascript\nconst svg = d3.select(\"body\").append(\"svg\")\n  .attr(\"width\", 960)\n  .attr(\"height\", 500);\n\nsvg.append(\"circle\")\n  .attr(\"cx\", 480)\n  .attr(\"cy\", 250)\n  .attr(\"r\", 240)\n  .style(\"fill\", \"purple\");\n\nsvg.append(\"text\")\n  .attr(\"x\", 480)\n  .attr(\"y\", 250)\n  .attr(\"text-anchor\", \"middle\")\n  .attr(\"dy\", \".3em\")\n  .text(\"Hello, D3.js!\");\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Best Practices\n\nAvoid Global Variables - Avoid using global variables in JavaScript.\n\n```javascript\n// Bad\nvar name = \"Alice\";\n\n// Good\nconst name = \"Alice\";\n```\n\nAvoid Declare Local Variables - Avoid declaring local variables without using the `var`, `let`, or `const` keyword.\n\n```javascript\n// Bad\nname = \"Alice\";\n\n// Good\nconst name = \"Alice\";\n```\n\nDeclarations on Top - Declare all variables at the beginning of every script or function.\n\n```javascript\n// Bad\nfunction myFunction() {\n  console.log(\"Hello, World!\");\n  var name = \"Alice\";\n}\n\n// Good\nfunction myFunction() {\n  var name = \"Alice\";\n  console.log(\"Hello, World!\");\n}\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nIntialize Variables - Always initialize variables when you declare them.\n\n```javascript\n// Bad\nlet name;\n\n// Good\nlet name = \"Alice\";\n```\n\nDeclare Objects with const - Use `const` to declare objects.\n\n```javascript\n// Bad\nlet person = {\n  name: \"Alice\",\n  age: 30\n};\n\n// Good\nconst person = {\n  name: \"Alice\",\n  age: 30\n};\n```\n\nDeclare Arrays with const - Use `const` to declare arrays.\n\n```javascript\n// Bad\nlet colors = [\"Red\", \"Green\", \"Blue\"];\n\n// Good\nconst colors = [\"Red\", \"Green\", \"Blue\"];\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nDon't Use new Objects - Avoid using the `new` keyword to create objects.\n\n```javascript\n// Bad\nlet person = new Object();\n\n// Good\nlet person = {};\n```\n\nBeware of Automatic Type Conversions - Be aware of automatic type conversions in JavaScript.\n\n```javascript\nconsole.log(10 + \"20\"); // Output: \"1020\"\n```\n\nUse === Comparison - Use the `===` operator to compare values and data types.\n\n```javascript\nconsole.log(10 === \"10\"); // Output: false\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nUse Parameter Defaults - Use parameter defaults to assign default values to function parameters.\n\n```javascript\nfunction greet(name = \"Alice\") {\n  console.log(\"Hello, \" + name + \"!\");\n}\n\ngreet(); // Output: \"Hello, Alice!\"\n```\n\nEnd Your Switches with Defaults - Always end your `switch` statements with a `default` case.\n\n```javascript\nswitch (new Date().getDay()) {\n  case 0:\n    day = \"Sunday\";\n    break;\n  case 1:\n    day = \"Monday\";\n    break;\n  case 2:\n    day = \"Tuesday\";\n    break;\n  case 3:\n    day = \"Wednesday\";\n    break;\n  case 4:\n    day = \"Thursday\";\n    break;\n  case 5:\n    day = \"Friday\";\n    break;\n  case 6:\n    day = \"Saturday\";\n    break;\n  default:\n    day = \"Unknown\";\n}\n\nconsole.log(day);\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nAvoid Number, String, and Boolean as Objects - Avoid using `Number`, `String`, or `Boolean` objects.\n\n```javascript\n// Bad\nlet x = new Number(500);\n\n// Good\nlet x = 500;\n```\n\nAvoid Using eval() - Avoid using the `eval()` function in JavaScript.\n\n```javascript\n// Bad\nlet x = eval(\"10 * 20\");\n\n// Good\nlet x = 10 * 20;\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Common Mistakes\n\nAccidentally Using the Assignment Operator - Be careful when using the assignment operator `=` instead of the equality operator `==` or `===`.\n\n```javascript\nlet x = 10;\n\nif (x = 10) {\n  console.log(\"Hello, World!\");\n}\n\n// Output: \"Hello, World!\"\n```\n\nExpecting Loose Comparison - Be aware of the differences between loose and strict comparison in JavaScript.\n\n```javascript\nconsole.log(10 == \"10\"); // Output: true\n```\n\nConfusing Addition \u0026 Concatenation - Be careful when adding numbers and strings in JavaScript.\n\n```javascript\nconsole.log(10 + 20); // Output: 30\n```\n\nMisundering Floats - Be aware of floating-point arithmetic in JavaScript.\n\n```javascript\nconsole.log(0.1 + 0.2); // Output: 0.30000000000000004\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nBreaking a JavaScript String - Be careful when breaking a string into multiple lines.\n\n```javascript\nlet text = \"Hello \\ World!\";\n\nconsole.log(text); // Output: \"Hello  World!\"\n```\n\nMisplacing semicolon - Be careful when misplacing semicolons in JavaScript.\n\n```javascript\nlet x = 10\nlet y = 20\n\nconsole.log(x + y); // Output: 30\n```\n\nBreaking a Return Statement - Be careful when breaking a return statement into multiple lines.\n\n```javascript\nfunction myFunction() {\n  return\n  \"Hello, World!\";\n}\n\nconsole.log(myFunction()); // Output: undefined\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nAccessing Arrays with Named Indexes - Be careful when accessing arrays with named indexes.\n\n```javascript\nlet person = [];\nperson[\"name\"] = \"Alice\";\nperson[\"age\"] = 30;\n\nconsole.log(person); // Output: []\n```\n\nEnding Definition with a Comma - Be careful when ending object definitions with a comma.\n\n```javascript\nlet person = {\n  name: \"Alice\",\n  age: 30,\n};\n\nconsole.log(person); // Output: { name: 'Alice', age: 30 }\n```\n\nUndefined is Not Null - Be aware of the difference between `undefined` and `null` in JavaScript.\n\n```javascript\nlet x;\n\nconsole.log(x); // Output: undefined\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Performance\n\nReduce Activity in Loops - Avoid unnecessary activity inside loops.\n\n```javascript\n// Bad\nfor (let i = 0; i \u003c 1000; i++) {\n  console.log(\"Hello, World!\");\n}\n\n// Good\nfor (let i = 0; i \u003c 1000; i++) {\n  // Do nothing\n}\n```\n\nReduce DOM Access - Minimize DOM access in JavaScript.\n\n```javascript\n// Bad\ndocument.getElementById(\"demo\").innerHTML = \"Hello, World!\";\n\n// Good\nlet element = document.getElementById(\"demo\");\nelement.innerHTML = \"Hello, World!\";\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nReduce DOM Size - Minimize the size of the DOM.\n\n```javascript\n// Bad\nfor (let i = 0; i \u003c 1000; i++) {\n  document.body.innerHTML += \"Hello, World!\";\n}\n\n// Good\nlet text = \"\";\nfor (let i = 0; i \u003c 1000; i++) {\n  text += \"Hello, World!\";\n}\n```\n\nAvoid Unnecessary Variables - Avoid unnecessary variables in JavaScript.\n\n```javascript\n// Bad\nlet x = 10;\nlet y = 20;\nlet z = x + y;\n\n// Good\nlet z = 10 + 20;\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nDelay Javascript Loading - Load JavaScript files at the end of the body tag.\n\n```javascript\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n  \u003ctitle\u003eDelay JavaScript Loading\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003ch1\u003eHello, World!\u003c/h1\u003e\n  \u003cscript src=\"script.js\"\u003e\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\nAvoid Using with - Avoid using the `with` statement in JavaScript.\n\n```javascript\n// Bad\nwith (document) {\n  let text = \"Hello, World!\";\n  console.log(text);\n}\n\n// Good\nlet text = \"Hello, World!\";\nconsole.log(text);\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## ES6 Features\n\nThe let keyword - The `let` keyword allows you to declare block-scoped variables.\n\n```javascript\nlet x = 10;\n\nif (x === 10) {\n  let y = 20;\n  console.log(x + y); // Output: 30\n}\n\nconsole.log(x + y); // Error: y is not defined\n```\n\nThe const keyword - The `const` keyword allows you to declare constants in JavaScript.\n\n```javascript\nconst PI = 3.14159;\nPI = 3.14; // Error: Assignment to constant variable\n\nconsole.log(PI); // Output: 3.14159\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nArrow Functions - Arrow functions provide a more concise syntax for writing function expressions.\n\n```javascript\nconst add = (x, y) =\u003e x + y;\n\nconsole.log(add(10, 20)); // Output: 30\n```\n\nThe ... Operator - The `...` operator allows you to spread elements of an array or object.\n\n```javascript\nconst arr1 = [1, 2, 3];\n\nconst arr2 = [...arr1, 4, 5, 6];\n\nconsole.log(arr2); // Output: [1, 2, 3, 4, 5, 6]\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nFor/of Loop - The `for...of` loop allows you to iterate over the values of an iterable object.\n\n```javascript\nconst colors = [\"Red\", \"Green\", \"Blue\"];\n\nfor (const color of colors) {\n  console.log(color);\n}\n\n// Output: Red, Green, Blue\n```\n\nMap Objects - The `Map` object allows you to store key-value pairs.\n\n```javascript\nconst map = new Map();\n\nmap.set(\"name\", \"Alice\");\n\nconsole.log(map.get(\"name\")); // Output: Alice\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nSet Objects - The `Set` object allows you to store unique values of any type.\n\n```javascript\nconst set = new Set();\n\nset.add(1);\n\nconsole.log(set.has(1)); // Output: true\n```\n\nClasses - Classes provide a more concise syntax for creating objects and dealing with inheritance.\n\n```javascript\nclass Person {\n  constructor(name, age) {\n    this.name = name;\n    this.age = age;\n  }\n\n  greet() {\n    console.log(`Hello, my name is ${this.name} and I am ${this.age} years old.`);\n  }\n}\n\nconst person = new Person(\"Alice\", 30);\n\nperson.greet(); // Output: Hello, my name is Alice and I am 30 years old.\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nPromises - Promises provide a more flexible way to handle asynchronous operations in JavaScript.\n\n```javascript\nconst promise = new Promise((resolve, reject) =\u003e {\n  setTimeout(() =\u003e {\n    resolve(\"Hello, World!\");\n  }, 2000);\n});\n\npromise.then((value) =\u003e {\n  console.log(value); // Output: Hello, World!\n});\n```\n\nSymbol - The `Symbol` object allows you to create unique values that can be used as object properties.\n\n```javascript\nconst key = Symbol(\"key\");\n\nconst obj = {};\n\nobj[key] = \"value\";\n\nconsole.log(obj[key]); // Output: value\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nDefault Parameters - Default parameters allow you to specify default values for function parameters.\n\n```javascript\nfunction greet(name = \"Alice\") {\n  console.log(`Hello, ${name}!`);\n}\n\ngreet(); // Output: Hello, Alice!\n```\n\nFunction Rest Parameter - The rest parameter allows you to pass an indefinite number of arguments to a function.\n\n```javascript\nfunction sum(...args) {\n  return args.reduce((acc, val) =\u003e acc + val, 0);\n}\n\nconsole.log(sum(1, 2, 3, 4, 5)); // Output: 15\n```\n\nString.includes() - The `includes()` method allows you to check if a string contains a specific substring.\n\n```javascript\nconst str = \"Hello, World!\";\n\nconsole.log(str.includes(\"World\")); // Output: true\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nString.startsWith() - The `startsWith()` method allows you to check if a string starts with a specific substring.\n\n```javascript\nconst str = \"Hello, World!\";\n\nconsole.log(str.startsWith(\"Hello\")); // Output: true\n```\n\nString.endsWith() - The `endsWith()` method allows you to check if a string ends with a specific substring.\n\n```javascript\nconst str = \"Hello, World!\";\nconsole.log(str.endsWith(\"World!\")); // Output: true\n```\n\nArray.from() - The `from()` method allows you to create an array from an array-like or iterable object.\n\n```javascript\nconst arr = Array.from(\"Hello\");\n\nconsole.log(arr); // Output: [\"H\", \"e\", \"l\", \"l\", \"o\"]\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nArray keys() - The `keys()` method returns an array iterator that contains the keys for each index in the array.\n\n```javascript\nconst arr = [\"a\", \"b\", \"c\"];\n\nconst iterator = arr.keys();\n\nfor (const key of iterator) {\n  console.log(key); // Output: 0, 1, 2\n}\n```\n\nArray find() - The `find()` method returns the first element in an array that satisfies a provided condition.\n\n```javascript\nconst arr = [1, 2, 3, 4, 5];\n\nconst result = arr.find((x) =\u003e x \u003e 3);\n\nconsole.log(result); // Output: 4\n```\n\nArray findIndex() - The `findIndex()` method returns the index of the first element in an array that satisfies a provided condition.\n\n```javascript\nconst arr = [1, 2, 3, 4, 5];\n\nconst index = arr.findIndex((x) =\u003e x \u003e 3);\n\nconsole.log(index); // Output: 3\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nNew Math Methods - The `Math` object in JavaScript provides several new methods in ES6.\n\n```javascript\nconsole.log(Math.cbrt(27)); // Output: 3\n```\n\nNew Number Properties - The `Number` object in JavaScript provides several new properties in ES6.\n\n```javascript\nconsole.log(Number.EPSILON); // Output: 2.220446049250313e-16\n```\n\nNew Number Methods - The `Number` object in JavaScript provides several new methods in ES6.\n\n```javascript\nconsole.log(Number.isInteger(10)); // Output: true\n```\n\nNew Global Methods - The global object in JavaScript provides several new methods in ES6.\n\n```javascript\nconsole.log(isFinite(10)); // Output: true\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nObject entries - The `Object.entries()` method returns an array of a given object's own enumerable property `[key, value]` pairs.\n\n```javascript\nconst obj = { name: \"Alice\", age: 30 };\n\nconst entries = Object.entries(obj);\n\nconsole.log(entries); // Output: [[\"name\", \"Alice\"], [\"age\", 30]]\n```\n\nJavaScript Modules - JavaScript modules allow you to split your code into multiple files and import/export functionality between them.\n\n```javascript\n// math.js\nexport const add = (x, y) =\u003e x + y;\n\n// main.js\nimport { add } from \"./math.js\";\n\nconsole.log(add(10, 20)); // Output: 30\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## ES5 Features\n\n\"use strict\" - The `\"use strict\"` directive is used to enable strict mode in JavaScript.\n\n```javascript\n\"use strict\";\n```\n\nString[number] access - You can access characters in a string using array-like syntax.\n\n```javascript\nconst str = \"Hello, World!\";\n\nconsole.log(str[0]); // Output: H\n```\n\nMultiline strings - You can create multiline strings in JavaScript using backticks.\n\n```javascript\nconst str = `Hello, \nWorld!`;\n\nconsole.log(str); // Output: Hello,\n                  //         World!\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nString.trim() - The `trim()` method removes whitespace from both ends of a string.\n\n```javascript\nconst str = \"  Hello, World!  \";\n\nconsole.log(str.trim()); // Output: \"Hello, World!\"\n```\n\nArray.isArray() - The `isArray()` method checks if a value is an array.\n\n```javascript\nconst arr = [1, 2, 3];\n\nconsole.log(Array.isArray(arr)); // Output: true\n```\n\nArray forEach() - The `forEach()` method executes a provided function once for each array element.\n\n```javascript\nconst arr = [1, 2, 3];\n\narr.forEach((x) =\u003e console.log(x));\n\n// Output: 1, 2, 3\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nArray map() - The `map()` method creates a new array with the results of calling a provided function on every element in the array.\n\n```javascript\nconst arr = [1, 2, 3];\n\nconst result = arr.map((x) =\u003e x * 2);\n\nconsole.log(result); // Output: [2, 4, 6]\n```\n\nArray filter() - The `filter()` method creates a new array with all elements that pass the test implemented by the provided function.\n\n```javascript\nconst arr = [1, 2, 3, 4, 5];\n\nconst result = arr.filter((x) =\u003e x % 2 === 0);\n\nconsole.log(result); // Output: [2, 4]\n```\n\nArray reduce() - The `reduce()` method applies a function against an accumulator and each element in the array (from left to right) to reduce it to a single value.\n\n```javascript\nconst arr = [1, 2, 3, 4, 5];\n\nconst result = arr.reduce((acc, val) =\u003e acc + val, 0);\n\nconsole.log(result); // Output: 15\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nArray reduceRight() - The `reduceRight()` method applies a function against an accumulator and each value of the array (from right-to-left) to reduce it to a single value.\n\n```javascript\nconst arr = [1, 2, 3, 4, 5];\n\nconst result = arr.reduceRight((acc, val) =\u003e acc + val, 0);\n\nconsole.log(result); // Output: 15\n```\n\nArray every() - The `every()` method tests whether all elements in the array pass the test implemented by the provided function.\n\n```javascript\nconst arr = [1, 2, 3, 4, 5];\n\nconst result = arr.every((x) =\u003e x \u003e 0);\n\nconsole.log(result); // Output: true\n```\n\nArray some() - The `some()` method tests whether at least one element in the array passes the test implemented by the provided function.\n\n```javascript\nconst arr = [1, 2, 3, 4, 5];\n\nconst result = arr.some((x) =\u003e x \u003e 3);\n\nconsole.log(result); // Output: true\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nArray indexOf() - The `indexOf()` method returns the first index at which a given element can be found in the array, or -1 if it is not present.\n\n```javascript\nconst arr = [1, 2, 3, 4, 5];\n\nconst index = arr.indexOf(3);\n\nconsole.log(index); // Output: 2\n```\n\nArray lastIndexOf() - The `lastIndexOf()` method returns the last index at which a given element can be found in the array, or -1 if it is not present.\n\n```javascript\nconst arr = [1, 2, 3, 4, 5, 3];\n\nconst index = arr.lastIndexOf(3);\n\nconsole.log(index); // Output: 5\n```\n\nJSON.parse() - The `parse()` method parses a JSON string and returns a JavaScript object.\n\n```javascript\nconst jsonString = '{\"name\": \"Alice\", \"age\": 30}';\n\nconst jsonObject = JSON.parse(jsonString);\n\nconsole.log(jsonObject); // Output: { name: 'Alice', age: 30 }\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nJSON.stringify() - The `stringify()` method converts a JavaScript object to a JSON string.\n\n```javascript\nconst jsonObject = { name: 'Alice', age: 30 };\n\nconst jsonString = JSON.stringify(jsonObject);\n\nconsole.log(jsonString); // Output: '{\"name\":\"Alice\",\"age\":30}'\n```\n\nDate.now() - The `now()` method returns the number of milliseconds elapsed since January 1, 1970.\n\n```javascript\nconst timestamp = Date.now();\n\nconsole.log(timestamp); // Output: 1633660800000\n```\n\nDate toISOString() - The `toISOString()` method returns a string in simplified extended ISO format.\n\n```javascript\nconst date = new Date();\n\nconsole.log(date.toISOString()); // Output: \"2021-10-08T07:00:00.000Z\"\n```\n\nDate toJSON() - The `toJSON()` method returns a string representation of the Date object.\n\n```javascript\nconst date = new Date();\n\nconsole.log(date.toJSON()); // Output: \"2021-10-08T07:00:00.000Z\"\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProperty getters and setters - Getters and setters allow you to define object properties that behave like methods.\n\n```javascript\nconst person = {\n  firstName: \"Alice\",\n  lastName: \"Smith\",\n  get fullName() {\n    return `${this.firstName} ${this.lastName}`;\n  },\n  set fullName(value) {\n    const parts = value.split(\" \");\n    this.firstName = parts[0];\n    this.lastName = parts[1];\n  }\n};\n\nconsole.log(person.fullName); // Output: \"Alice Smith\"\n```\n\nReserved words as property names - You can use reserved words as property names in JavaScript.\n\n```javascript\nconst person = {\n  class: \"A\",\n  function: \"greet\"\n};\n\nconsole.log(person.class); // Output: \"A\"\n```\n\nObject Methods - The `Object` object provides several methods for working with objects in JavaScript.\n\n```javascript\nconst obj = { name: \"Alice\", age: 30 };\n\nconst keys = Object.keys(obj);\n\nconsole.log(keys); // Output: [\"name\", \"age\"]\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nObject defineProperty() - The `defineProperty()` method defines a new property directly on an object, or modifies an existing property.\n\n```javascript\nconst obj = {};\n\nObject.defineProperty(obj, \"name\", {\n  value: \"Alice\",\n  writable: true,\n  enumerable: true,\n  configurable: true\n});\n\nconsole.log(obj.name); // Output: \"Alice\"\n```\n\nFunction bind() - The `bind()` method creates a new function that, when called, has its `this` keyword set to the provided value.\n\n```javascript\nconst person = {\n  name: \"Alice\",\n  greet: function() {\n    console.log(`Hello, my name is ${this.name}.`);\n  }\n};\n\nconst greet = person.greet.bind(person);\n\ngreet(); // Output: \"Hello, my name is Alice.\"\n```\n\nTrailing commas - Trailing commas are allowed in JavaScript.\n\n```javascript\nconst arr = [\n  1,\n  2,\n  3,\n];\n\nconsole.log(arr); // Output: [1, 2, 3]\n```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Snippets\n\nHere are a few JavaScript snippets that you might find useful:\n\n1. **Hello World:**\n\n   ```javascript\n   console.log(\"Hello, World!\");\n   ```\n\n2. **Variable Declaration:**\n\n   ```javascript\n   let variableName = \"Some value\";\n   ```\n\n3. **Conditional Statement (if-else):**\n\n   ```javascript\n   let condition = true;\n\n   if (condition) {\n       console.log(\"Condition is true\");\n   } else {\n       console.log(\"Condition is false\");\n   }\n   ```\n\n4. **Loop (for):**\n\n   ```javascript\n   for (let i = 0; i \u003c 5; i++) {\n       console.log(i);\n   }\n   ```\n\n5. **Function Declaration:**\n\n   ```javascript\n   function greet(name) {\n       console.log(\"Hello, \" + name + \"!\");\n   }\n\n   greet(\"John\");\n   ```\n\n6. **Array Manipulation:**\n\n   ```javascript\n   let fruits = ['Apple', 'Banana', 'Orange'];\n\n   // Add an element to the end\n   fruits.push('Mango');\n\n   // Remove the last element\n   fruits.pop();\n\n   // Access elements by index\n   console.log(fruits[1]);\n   ```\n\n7. **Object Declaration:**\n\n   ```javascript\n   let person = {\n       name: 'John',\n       age: 25,\n       profession: 'Developer'\n   };\n\n   // Accessing object properties\n   console.log(person.name);\n   ```\n\n8. **Async/Await:**\n\n   ```javascript\n   async function fetchData() {\n       try {\n           let response = await fetch('https://api.example.com/data');\n           let data = await response.json();\n           console.log(data);\n       } catch (error) {\n           console.error('Error fetching data:', error);\n       }\n   }\n\n   fetchData();\n   ```\n\n9. **Event Handling:**\n\n   ```javascript\n   let button = document.getElementById('myButton');\n\n   button.addEventListener('click', function() {\n       console.log('Button clicked!');\n   });\n   ```\n\n10. **LocalStorage:**\n\n    ```javascript\n    // Save data to local storage\n    localStorage.setItem('username', 'JohnDoe');\n\n    // Retrieve data from local storage\n    let storedUsername = localStorage.getItem('username');\n    console.log('Username:', storedUsername);\n    ```\n\n11. **Error Handling:**\n\n    ```javascript\n    try {\n        // Code that may throw an error\n        throw new Error('Something went wrong');\n    } catch (error) {\n        console.error('Error:', error.message);\n    }\n    ```\n\n12. **Regular Expression:**\n\n    ```javascript\n    let pattern = /hello/i; // Case-insensitive match for 'hello'\n\n    let text = 'Hello, World!';\n    let result = pattern.test(text);\n\n    console.log(result); // Output: true\n    ```\n\n13. **Math Operations:**\n\n    ```javascript\n    let x = 10;\n\n    console.log(Math.sqrt(x)); // Square root\n\n    console.log(Math.pow(x, 2)); // x raised to the power of 2\n\n    console.log(Math.random()); // Random number between 0 and 1\n    ```\n\n14. **Date and Time:**\n\n    ```javascript\n    let date = new Date();\n\n    console.log(date.toDateString()); // Date in human-readable format\n\n    console.log(date.getHours()); // Current hour\n    ```\n\n15. **Set Timeout:**\n\n    ```javascript\n    setTimeout(function() {\n        console.log('Timeout completed');\n    }, 2000); // 2 seconds\n    ```\n\n16. **Set Interval:**\n\n    ```javascript\n    let counter = 0;\n\n    let interval = setInterval(function() {\n        console.log('Counter:', counter);\n        counter++;\n\n        if (counter === 5) {\n            clearInterval(interval);\n        }\n    }, 1000); // Every 1 second\n    ```\n\n17. **Fetch API:**\n\n    ```javascript\n    fetch('https://api.example.com/data')\n        .then(response =\u003e response.json())\n        .then(data =\u003e console.log(data))\n        .catch(error =\u003e console.error('Error fetching data:', error));\n    ```\n\n18. **Arrow Functions:**\n\n    ```javascript\n    let add = (x, y) =\u003e x + y;\n\n    console.log(add(5, 3)); // Output: 8\n    ```\n\n19. **Template Literals:**\n\n    ```javascript\n    let name = 'Alice';\n    let greeting = `Hello, ${name}!`;\n\n    console.log(greeting); // Output: Hello, Alice!\n    ```\n\n20. **Destructuring Assignment:**\n\n    ```javascript\n    let person = { name: 'John', age: 30 };\n\n    let { name, age } = person;\n\n    console.log(name, age); // Output: John 30\n    ```\n\n21. **Spread Operator:**\n\n    ```javascript\n    let numbers = [1, 2, 3];\n    let newNumbers = [...numbers, 4, 5];\n\n    console.log(newNumbers); // Output: [1, 2, 3, 4, 5]\n    ```\n\n22. **Promise:**\n\n    ```javascript\n    let promise = new Promise((resolve, reject) =\u003e {\n        setTimeout(() =\u003e {\n            resolve('Promise resolved');\n        }, 2000);\n    });\n\n    promise.then(result =\u003e console.log(result));\n    ```\n\n23. **Map Function:**\n\n    ```javascript\n    let numbers = [1, 2, 3, 4, 5];\n\n    let squaredNumbers = numbers.map(num =\u003e num * num);\n\n    console.log(squaredNumbers); // Output: [1, 4, 9, 16, 25]\n    ```\n\n24. **Filter Function:**\n\n    ```javascript\n    let numbers = [1, 2, 3, 4, 5];\n\n    let evenNumbers = numbers.filter(num =\u003e num % 2 === 0);\n\n    console.log(evenNumbers); // Output: [2, 4]\n    ```\n\n25. **Reduce Function:**\n\n    ```javascript\n    let numbers = [1, 2, 3, 4, 5];\n\n    let sum = numbers.reduce((acc, num) =\u003e acc + num, 0);\n\n    console.log(sum); // Output: 15\n    ```\n\n26. **Find Function:**\n\n    ```javascript\n    let numbers = [1, 2, 3, 4, 5];\n\n    let foundNumber = numbers.find(num =\u003e num \u003e 3);\n\n    console.log(foundNumber); // Output: 4\n    ```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Short Hands\n\nJavaScript offers several shorthand techniques to write code more concisely and improve readability. Here are some common JavaScript shorthand techniques:\n\n1. **Ternary Operator:**\n\n   Instead of using an `if-else` statement, you can use the ternary operator for concise conditional expressions.\n\n   ```javascript\n   // Long form\n   let result;\n   if (condition) {\n       result = 'true';\n   } else {\n       result = 'false';\n   }\n\n   // Shorthand\n   let result = condition ? 'true' : 'false';\n   ```\n\n2. **Nullish Coalescing Operator (`??`):**\n\n   This operator provides a concise way to provide a default value if a variable is null or undefined.\n\n   ```javascript\n   // Long form\n   let value;\n   if (value !== null \u0026\u0026 value !== undefined) {\n       result = value;\n   } else {\n       result = 'default';\n   }\n\n   // Shorthand\n   let result = value ?? 'default';\n   ```\n\n3. **Arrow Functions:**\n\n   Arrow functions provide a concise syntax for writing function expressions.\n\n   ```javascript\n   // Long form\n   function add(x, y) {\n       return x + y;\n   }\n\n   // Shorthand\n   const add = (x, y) =\u003e x + y;\n   ```\n\n4. **Template Literals:**\n\n   Template literals make it easier to concatenate strings and include variables within strings.\n\n   ```javascript\n   // Long form\n   const greeting = 'Hello, ' + name + '!';\n\n   // Shorthand\n   const greeting = `Hello, ${name}!`;\n   ```\n\n5. **Object Property Shorthand:**\n\n   When creating an object with properties that have the same name as the variables being assigned, you can use shorthand notation.\n\n   ```javascript\n   // Long form\n   const name = 'John';\n   const age = 30;\n   const user = {\n       name: name,\n       age: age\n   };\n\n   // Shorthand\n   const user = {\n       name,\n       age\n   };\n   ```\n\n6. **Destructuring Assignment:**\n\n   Destructuring allows you to extract values from arrays or objects and assign them to variables in a concise way.\n\n   ```javascript\n   // Long form\n   const person = { name: 'John', age: 30 };\n   const name = person.name;\n   const age = person.age;\n\n   // Shorthand\n   const { name, age } = { name: 'John', age: 30 };\n   ```\n\n7. **Default Parameters:**\n\n    Default parameters allow you to specify default values for function parameters.\n  \n    ```javascript\n    // Long form\n    function greet(name) {\n        if (name === undefined) {\n            name = 'World';\n        }\n        console.log('Hello, ' + name + '!');\n    }\n  \n    // Shorthand\n    function greet(name = 'World') {\n        console.log('Hello, ' + name + '!');\n    }\n    ```\n\n8. **Array and Object Spread:**\n\n    The spread operator (`...`) allows you to spread the elements of an array or object into another array or object.\n\n    ```javascript\n    // Long form\n    const numbers = [1, 2, 3];\n    const newNumbers = [...numbers, 4, 5];\n\n    // Shorthand\n    const newNumbers = [...numbers, 4, 5];\n    ```\n\n    ```javascript\n    // Long form\n    const person = { name: 'John', age: 30 };\n\n    const updatedPerson = {\n        name: person.name,\n        age: person.age,\n        profession: 'Developer\n    };\n\n    // Shorthand\n    const updatedPerson = { ...person, profession: 'Developer };\n    ```\n\n9. **Array Destructuring:**\n\n    Array destructuring allows you to extract values from arrays and assign them to variables in a concise way.\n\n    ```javascript\n    // Long form\n    const numbers = [1, 2, 3];\n    const first = numbers[0];\n    const second = numbers[1];\n\n    // Shorthand\n    const [first, second] = [1, 2, 3];\n    ```\n\n10. **Object Destructuring:**\n\n    Object destructuring allows you to extract values from objects and assign them to variables in a concise way.\n\n    ```javascript\n    // Long form\n    const person = { name: 'John', age: 30 };\n    const name = person.name;\n    const age = person.age;\n\n    // Shorthand\n    const { name, age } = { name: 'John', age: 30 };\n    ```\n\n11. **Short-Circuit Evaluation:**\n\n    Short-circuit evaluation allows you to write concise conditional expressions using logical operators.\n\n    ```javascript\n    // Long form\n    let result;\n    if (condition) {\n        result = value;\n    } else {\n        result = 'default';\n    }\n\n    // Shorthand\n    let result = condition \u0026\u0026 value || 'default';\n    ```\n\n    ```javascript\n    // Long form\n    let result;\n    if (condition) {\n        result = 'true';\n    } else {\n        result = 'false';\n    }\n\n    // Shorthand\n    let result = condition ? 'true' : 'false';\n    ```\n\n    ```javascript\n    // Long form\n    let result;\n\n    if (value !== null \u0026\u0026 value !== undefined) {\n        result = value;\n    } else {\n        result = 'default';\n    }\n\n    // Shorthand\n    let result = value ?? 'default';\n    ```\n\n12. **Logical Assignment Operators:**\n\n    Logical assignment operators provide a concise way to update a variable based on a condition.\n\n    ```javascript\n    // Long form\n    let count = 0;\n    if (count === 0) {\n        count = 1;\n    }\n\n    // Shorthand\n    let count = 0;\n    count ||= 1;\n    ```\n\n    ```javascript\n    // Long form\n    let count = 0;\n    if (count === 0) {\n        count += 1;\n    }\n\n    // Shorthand\n    let count = 0;\n    count += 1;\n    ```\n\n13. **Optional Chaining:**\n\n    Optional chaining allows you to access nested properties of an object without having to check for the existence of each property.\n\n    ```javascript\n    // Long form\n    let result;\n    if (data \u0026\u0026 data.user \u0026\u0026 data.user.name) {\n        result = data.user.name;\n    } else {\n        result = 'Unknown';\n    }\n\n    // Shorthand\n    let result = data?.user?.name ?? 'Unknown';\n    ```\n\n14. **Promise Chaining:**\n\n    Promise chaining allows you to chain multiple asynchronous operations in a concise way.\n\n    ```javascript\n    // Long form\n    fetch('https://api.example.com/data')\n        .then(response =\u003e response.json())\n        .then(data =\u003e {\n            console.log(data);\n            return fetch('https://api.example.com/other-data');\n        })\n        .then(response =\u003e response.json())\n        .then(otherData =\u003e console.log(otherData))\n        .catch(error =\u003e console.error('Error:', error));\n\n    // Shorthand\n    fetch('https://api.example.com/data')\n        .then(response =\u003e response.json())\n        .then(data =\u003e console.log(data))\n        .then(() =\u003e fetch('https://api.example.com/other-data'))\n        .then(response =\u003e response.json())\n        .then(otherData =\u003e console.log(otherData))\n        .catch(error =\u003e console.error('Error:', error));\n    ```\n\n15. **Async/Await:**\n\n    Async/await provides a more concise way to work with asynchronous code compared to promises.\n\n    ```javascript\n    // Long form\n    function fetchData() {\n        return fetch('https://api.example.com/data')\n            .then(response =\u003e response.json());\n    }\n\n    fetchData()\n        .then(data =\u003e console.log(data))\n        .catch(error =\u003e console.error('Error:', error));\n\n    // Shorthand\n    async function fetchData() {\n        try {\n            let response = await fetch('https://api.example.com/data');\n            let data = await response.json();\n            console.log(data);\n        } catch (error) {\n            console.error('Error:', error);\n        }\n    }\n\n    fetchData();\n    ```\n\n16. **Array Methods:**\n\n    JavaScript array methods provide a concise way to perform common operations on arrays.\n\n    ```javascript\n    // Long form\n    const numbers = [1, 2, 3, 4, 5];\n    const squaredNumbers = numbers.map(num =\u003e num * num);\n\n    // Shorthand\n    const squaredNumbers = [1, 2, 3, 4, 5].map(num =\u003e num * num);\n    ```\n\n    ```javascript\n    // Long form\n    const numbers = [1, 2, 3, 4, 5];\n    const evenNumbers = numbers.filter(num =\u003e num % 2 === 0);\n\n    // Shorthand\n    const evenNumbers = [1, 2, 3, 4, 5].filter(num =\u003e num % 2 === 0);\n    ```\n\n    ```javascript\n    // Long form\n    const numbers = [1, 2, 3, 4, 5];\n    const sum = numbers.reduce((acc, num) =\u003e acc + num, 0);\n\n    // Shorthand\n    const sum = [1, 2, 3, 4, 5].reduce((acc, num) =\u003e acc + num, 0);\n    ```\n\n    ```javascript\n    // Long form\n    const numbers = [1, 2, 3, 4, 5];\n    const foundNumber = numbers.find(num =\u003e num \u003e 3);\n\n    // Shorthand\n    const foundNumber = [1, 2, 3, 4, 5].find(num =\u003e num \u003e 3);\n    ```\n\n17. **Object Methods:**\n\n    JavaScript object methods provide a concise way to perform common operations on objects.\n\n    ```javascript\n    // Long form\n    const person = { name: 'John', age: 30 };\n    const keys = Object.keys(person);\n\n    // Shorthand\n    const keys = Object.keys({ name: 'John', age: 30 });\n    ```\n\n    ```javascript\n    // Long form\n    const person = { name: 'John', age: 30 };\n    const values = Object.values(person);\n\n    // Shorthand\n    const values = Object.values({ name: 'John', age: 30 });\n    ```\n\n    ```javascript\n    // Long form\n    const person = { name: 'John', age: 30 };\n    const entries = Object.entries(person);\n\n    // Shorthand\n    const entries = Object.entries({ name: 'John', age: 30 });\n    ```\n\n    ```javascript\n    // Long form\n    const person = { name: 'John', age: 30 };\n    const copy = Object.assign({}, person);\n\n    // Shorthand\n    const copy = { ...{ name: 'John', age: 30 } };\n    ```\n\n18. **Function Methods:**\n\n    JavaScript function methods provide a concise way to work with functions.\n\n    ```javascript\n    // Long form\n    function greet(name) {\n        console.log('Hello, ' + name + '!');\n    }\n\n    // Shorthand\n    const greet = name =\u003e console.log('Hello, ' + name + '!');\n    ```\n\n    ```javascript\n    // Long form\n    function add(x, y) {\n        return x + y;\n    }\n\n    // Shorthand\n    const add = (x, y) =\u003e x + y;\n    ```\n\n    ```javascript\n    // Long form\n    function multiply(x, y) {\n        return x * y;\n    }\n\n    // Shorthand\n    const multiply = (x, y) =\u003e x * y;\n    ```\n\n    ```javascript\n    // Long form\n    function divide(x, y) {\n        return x / y;\n    }\n\n    // Shorthand\n    const divide = (x, y) =\u003e x / y;\n    ```\n\n19. **String Methods:**\n\n    JavaScript string methods provide a concise way to work with strings.\n\n    ```javascript\n    // Long form\n    const text = 'Hello, World!';\n    const trimmedText = text.trim();\n\n    // Shorthand\n    const trimmedText = '  Hello, World!  '.trim();\n    ```\n\n    ```javascript\n    // Long form\n    const text = 'Hello, World!';\n    const uppercaseText = text.toUpperCase();\n\n    // Shorthand\n    const uppercaseText = 'Hello, World!'.toUpperCase();\n    ```\n\n    ```javascript\n    // Long form\n    const text = 'Hello, World!';\n    const lowercaseText = text.toLowerCase();\n\n    // Shorthand\n    const lowercaseText = 'Hello, World!'.toLowerCase();\n    ```\n\n    ```javascript\n    // Long form\n    const text = 'Hello, World!';\n    const length = text.length;\n\n    // Shorthand\n    const length = 'Hello, World!'.length;\n    ```\n\n20. **Number Methods:**\n\n    JavaScript number methods provide a concise way to work with numbers.\n\n    ```javascript\n    // Long form\n    const number = 3.14159;\n    const roundedNumber = Math.round(number);\n\n    // Shorthand\n    const roundedNumber = Math.round(3.14159);\n    ```\n\n    ```javascript\n    // Long form\n    const number = 3.14159;\n    const squaredNumber = Math.pow(number, 2);\n\n    // Shorthand\n    const squaredNumber = Math.pow(3.14159, 2);\n    ```\n\n    ```javascript\n    // Long form\n    const number = 3.14159;\n    const squareRoot = Math.sqrt(number);\n\n    // Shorthand\n    const squareRoot = Math.sqrt(3.14159);\n    ```\n\n    ```javascript\n    // Long form\n    const number = 3.14159;\n    const absoluteValue = Math.abs(number);\n\n    // Shorthand\n    const absoluteValue = Math.abs(3.14159);\n    ```\n\n21. **Date Methods:**\n\n    JavaScript date methods provide a concise way to work with dates.\n\n    ```javascript\n    // Long form\n    const date = new Date();\n    const day = date.getDate();\n\n    // Shorthand\n    const day = new Date().getDate();\n    ```\n\n    ```javascript\n    // Long form\n    const date = new Date();\n    const month = date.getMonth();\n\n    // Shorthand\n    const month = new Date().getMonth();\n    ```\n\n    ```javascript\n    // Long form\n    const date = new Date();\n    const year = date.getFullYear();\n\n    // Shorthand\n    const year = new Date().getFullYear();\n    ```\n\n    ```javascript\n    // Long form\n    const date = new Date();\n    const hours = date.getHours();\n\n    // Shorthand\n    const hours = new Date().getHours();\n    ```\n\n22. **Math Methods:**\n\n    JavaScript math methods provide a concise way to perform mathematical operations.\n\n    ```javascript\n    // Long form\n    const number = 3.14159;\n    const roundedNumber = Math.round(number);\n\n    // Shorthand\n    const roundedNumber = Math.round(3.14159);\n    ```\n\n    ```javascript\n    // Long form\n    const number = 3.14159;\n    const squaredNumber = Math.pow(number, 2);\n\n    // Shorthand\n    const squaredNumber = Math.pow(3.14159, 2);\n    ```\n\n    ```javascript\n    // Long form\n    const number = 3.14159;\n    const squareRoot = Math.sqrt(number);\n\n    // Shorthand\n    const squareRoot = Math.sqrt(3.14159);\n    ```\n\n    ```javascript\n    // Long form\n    const number = 3.14159;\n    const absoluteValue = Math.abs(number);\n\n    // Shorthand\n    const absoluteValue = Math.abs(3.14159);\n    ```\n\n23. **Array Methods:**\n\n    JavaScript array methods provide a concise way to perform common operations on arrays.\n\n    ```javascript\n    // Long form\n    const numbers = [1, 2, 3, 4, 5];\n    const squaredNumbers = numbers.map(num =\u003e num * num);\n\n    // Shorthand\n    const squaredNumbers = [1, 2, 3, 4, 5].map(num =\u003e num * num);\n    ```\n\n    ```javascript\n    // Long form\n    const numbers = [1, 2, 3, 4, 5];\n    const evenNumbers = numbers.filter(num =\u003e num % 2 === 0);\n\n    // Shorthand\n    const evenNumbers = [1, 2, 3, 4, 5].filter(num =\u003e num % 2 === 0);\n    ```\n\n    ```javascript\n    // Long form\n    const numbers = [1, 2, 3, 4, 5];\n    const sum = numbers.reduce((acc, num) =\u003e acc + num, 0);\n\n    // Shorthand\n    const sum = [1, 2, 3, 4, 5].reduce((acc, num) =\u003e acc + num, 0);\n    ```\n\n    ```javascript\n    // Long form\n    const numbers = [1, 2, 3, 4, 5];\n    const foundNumber = numbers.find(num =\u003e num \u003e 3);\n\n    // Shorthand\n    const foundNumber = [1, 2, 3, 4, 5].find(num =\u003e num \u003e 3);\n    ```\n\n[Back to Top⤴️](#table-of-contents)\n\n## Interview Questions\n\nSorts an array of numbers without using any built-in method.\n\n```javascript\nconst sortArray = (arr) =\u003e {\n  for (let i = 0; i \u003c arr.length; i++) {\n    for (let j = i + 1; j \u003c arr.length; j++) {\n      if (arr[i] \u003e arr[j]) {\n        let temp = arr[i];\n        arr[i] = arr[j];\n        arr[j] = temp;\n      }\n    }\n  }\n  return arr;\n};\n\nconst numbers = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5];\nconsole.log(sortArray(numbers)); // Output: [1, 1, 2, 3, 3, 4, 5, 5, 5, 6, 9]\n```\n\nFind the maximum number in an array of numbers without using any built-in method.\n\n```javascript\nconst findMax = (arr) =\u003e {\n  let max = arr[0];\n  for (let i = 1; i \u003c arr.length; i++) {\n    if (arr[i] \u003e max) {\n      max = arr[i];\n    }\n  }\n  return max;\n};\n\nconst numbers = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5];\nconsole.log(findMax(numbers)); // Output: 9\n```\n\nFind the minimum number in an array of numbers without using any built-in method.\n\n```javascript\nconst findMin = (arr) =\u003e {\n  let min = arr[0];\n  for (let i = 1; i \u003c arr.length; i++) {\n    if (arr[i] \u003c min) {\n      min = arr[i];\n    }\n  }\n  return min;\n};\n\nconst numbers = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5];\nconsole.log(findMin(numbers)); // Output: 1\n```\n\nFind the second largest number from the array given\n\n```javascript\nlet array = [1, 8, 9, 40, 50];\n\nconst secondLar = (arr) =\u003e {\n    let first = -Infinity;\n    let second = -Infinity;    \n    for (let i = 0; i \u003c arr.length; i++){\n\n        if( arr[i] \u003e first){\n            second = first;\n            first = arr[i];\n        } else if (arr[i] \u003e second \u0026\u0026 arr[i] != first){\n            second = arr[i];\n        }\n    }\n    return second === -Infinity ? \"No second largest number\" : second;\n}\n\nconsole.log(secondLar(array));\n```\n\nRemove special characters from the given string without using built-in methods:\n\n```javascript\nconst input = \"MA@NT+H(A+N)\";\n\nconst remove = (str) =\u003e {\n    let result = '';\n    for (let i = 0; i \u003c str.length; i++){\n        let char = str[i];\n        if(\n            (char \u003e= 'A' \u0026\u0026 char \u003c= 'Z') ||\n            (char \u003e= 'a' \u0026\u0026 char \u003c= 'z') ||\n            (char \u003e= '0' \u0026\u0026 char \u003c= '9') || \n            char === ' '\n        ){\n            result += char;\n        }\n    }\n    return result;\n}\n\nconsole.log(remove(input)); // Output=MANTHAN\n```\n\nPrint the given values in matrix form without using built-in methods\n\n```javascript\nOutput: \n1   4   7   \n2   5   8   \n3   6   9\n\nlet input = [1, 2, 3, 4, 5, 6, 7, 8, 9];\n\n// Manually print the matrix\nfor (let row = 0; row \u003c 3; row++) {\n    let output = \"\";  // Initialize an empty string for each row\n    for (let col = 0; col \u003c 3; col++) {\n        output += input[row + col * 3] + \"   \";  // Calculate index and add spaces\n    }\n    console.log(output);\n}\n```\n\nWrite a function that calculates the sum of an array of numbers Without Inbuilt Method.\n\n```javascript\nfunction sumArray(arr) {\n  let sum = 0;\n  for (let i = 0; i \u003c arr.length; i++) {\n    sum += arr[i];\n  }\n  return sum;\n}\n\nconst numbers = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5];\nconsole.log(sumArray(numbers)); // Output: 44\n```\n\nWrite a function that calculates the average of an array of numbers Without Inbuilt Method.\n\n```javascript\nfunction averageArray(arr) {\n  let sum = 0;\n  for (let i = 0; i \u003c arr.length; i++) {\n    sum += arr[i];\n  }\n  return sum / arr.length;\n}\n\nconst numbers = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5];\nconsole.log(averageArray(numbers)); // Output: 4\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nWrite a function that checks if a number is prime Without Inbuilt Method.\n\n```javascript\nfunction isPrime(num) {\n  if (num \u003c= 1) {\n    return false;\n  }\n  for (let i = 2; i \u003c= Math.sqrt(num); i++) {\n    if (num % i === 0) {\n      return false;\n    }\n  }\n  return true;\n}\n\nconsole.log(isPrime(7)); // Output: true\nconsole.log(isPrime(10)); // Output: false\n```\n\nWrite a function that checks if a number is a palindrome Without Inbuilt Method.\n\n```javascript\nfunction isPalindrome(num) {\n  const str = num.toString();\n  for (let i = 0; i \u003c str.length / 2; i++) {\n    if (str[i] !== str[str.length - 1 - i]) {\n      return false;\n    }\n  }\n  return true;\n}\n\nconsole.log(isPalindrome(121)); // Output: true\nconsole.log(isPalindrome(123)); // Output: false\n```\n\nWrite a function that checks if a string is a palindrome Without Inbuilt Method.\n\n```javascript\nfunction isPalindrome(str) {\n  for (let i = 0; i \u003c str.length / 2; i++) {\n    if (str[i] !== str[str.length - 1 - i]) {\n      return false;\n    }\n  }\n  return true;\n}\n\nconsole.log(isPalindrome('madam')); // Output: true\nconsole.log(isPalindrome('hello')); // Output: false\n```\n\nFind duplicate numbers in an array without using any built-in method.\n\n```javascript\nconst findDuplicates = (arr) =\u003e {\n  let duplicates = [];\n  let index = 0;\n  for (let i = 0; i \u003c arr.length; i++) {\n    for (let j = i + 1; j \u003c arr.length; j++) {\n      let isDuplicate = false;\n      if (arr[i] === arr[j]) {\n        for (let k = 0; k \u003c index; k++) {\n          if (duplicates[k] === arr[i]) {\n            isDuplicate = true;\n            break;\n          }\n        }\n        if (!isDuplicate) {\n          duplicates[index] = arr[i];\n          index++;\n        }\n      }\n    }\n  }\n  return duplicates;\n};\n\nlet numbers = [1, 2, 3, 4, 2, 5, 6, 3, 7, 8, 8];\nconsole.log(findDuplicates(numbers)); // Output: [2, 3, 8]\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nRemove duplicate numbers in an array without using any built-in method.\n\n```javascript\nconst removeDuplicates = (arr) =\u003e {\n  let unique = [];\n  let index = 0;\n\n  for (let i = 0; i \u003c arr.length; i++) {\n    let isDuplicate = false;\n    for (let j = 0; j \u003c index; j++) {\n      if (arr[i] === unique[j]) {\n        isDuplicate = true;\n        break;\n      }\n    }\n    if (!isDuplicate) {\n      unique[index] = arr[i];\n      index++;\n    }\n  }\n  return unique;\n};\n\nlet numbers = [1, 2, 3, 4, 2, 5, 6, 3, 7, 8, 8];\nconsole.log(removeDuplicates(numbers)); // Output: [1, 2, 3, 4, 5, 6, 7, 8]\n```\n\nReverse a string without using any built-in method.\n\n```javascript\nconst reverseString = (str) =\u003e {\n  let reversed = '';\n  for (let i = str.length - 1; i \u003e= 0; i--) {\n    reversed += str[i];\n  }\n  return reversed;\n};\n\nconsole.log(reverseString('hello')); // Output: 'olleh'\n```\n\nReverse a number without using any built-in method.\n\n```javascript\nconst reverseNumber = (num) =\u003e {\n  let reversed = 0;\n  while (num \u003e 0) {\n    reversed = reversed * 10 + (num % 10);\n    num = Math.floor(num / 10);\n  }\n  return reversed;\n};\n\nconsole.log(reverseNumber(12345)); // Output: 54321\n```\n\nPrint only id's from the below array\n\n```jsx\nconst nameList = [{\n  name: 'a',\n  id: '1'\n},\n{\n  name: 'b',\n  id: '2'\n}, {\n  name: 'c',\n  id: '3'\n}]\n\n// solution using built-in method or funtion\nconst ids = nameList.map(item =\u003e item.id);\nconsole.log(ids); // ['1', '2', '3']\n\n// solution using without built-in method or funtion\nlet ids = [];\nfor (let i = 0; i \u003c nameList.length; i++) {\n  ids[i] = nameList[i].id;\n}\nconsole.log(ids); // ['1', '2', '3']\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nPrint the output as shown below\n\n```jsx\n// output\nOutPutArray=[{amount:300,name:'a',id:'1'},{amount:300,name:'b',id:'2'},{amount:300,name:'c',id:'3'}]\n\n// solution\nconst nameList = {\n  amount: 300,\n  name: [{\n    name: 'a',\n    id: '1'\n  },\n  {\n    name: 'b',\n    id: '2'\n  }, {\n    name: 'c',\n    id: '3'\n  }]\n}\n\n// solution using built-in method or funtion\nconst outputArray = nameList.name.map(item =\u003e ({ ...item, amount: nameList.amount }));\nconsole.log(outputArray); // [{amount:300,name:'a',id:'1'},{amount:300,name:'b',id:'2'},{amount:300,name:'c',id:'3'}]\n\n// solution using without built-in method or funtion\nlet outputArray = [];\nfor (let i = 0; i \u003c nameList.name.length; i++) {\n  outputArray[i] = {\n    amount: nameList.amount,\n    name: nameList.name[i].name,\n    id: nameList.name[i].id\n  };\n}\nconsole.log(outputArray); // [{amount:300,name:'a',id:'1'},{amount:300,name:'b',id:'2'},{amount:300,name:'c',id:'3'}]\n```\n\nPrint a half pyramid in JavaScript as shown below\n\n```jsx\n// output \n// *\n// **\n// ***\n\n// solution using built-in method or funtion\nfor (let i = 1; i \u003c= 3; i++) {\n  console.log('*'.repeat(i));\n}\n\n// solution using without built-in method or funtion\nfor (let i = 1; i \u003c= 3; i++) {\n  let string = '';\n  for (let j = 1; j \u003c= i; j++) {\n    string += '*';\n  }\n  console.log(string);\n}\n\n// solution using without built-in method or funtion\nlet string = \"\";\n\nfor (let i = 0; i \u003c 3; i++){\n    string += '*';\n    console.log(string);\n}\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nPrint a inverted half pyramid in JavaScript as shown below\n\n```jsx\n// output \n// ***\n// **\n// *\n\n// solution using built-in method or funtion\nfor (let i = 3; i \u003e= 1; i--) {\n  console.log('*'.repeat(i));\n}\n\n// solution using without built-in method or funtion\nfor (let i = 3; i \u003e= 1; i--) {\n  let string = '';\n  for (let j = 1; j \u003c= i; j++) {\n    string += '*';\n  }\n  console.log(string);\n}\n```\n\nPrint the output as shown below\n\n```javascript\n// OUTPUT\n// {\n//   \"odd\" : all odd nums,\n//   \"even\": all even numbers\n// }\n\nlet nums = [2, 5, 3, 6, 8, 5];\n\n// solution using built-in method or funtion\nlet evenNums = nums.filter((num) =\u003e num % 2 === 0);\nlet oddNums = nums.filter((num) =\u003e num % 2 !== 0);\n\nlet result = {\n  \"odd\": oddNums,\n  \"even\": evenNums\n};\n\nconsole.log(result);\n\n// solution using without built-in method or funtion\nlet evenNums = [];\nlet oddNums = [];\n\nfor (let i = 0; i \u003c nums.length; i++) {\n  if (nums[i] % 2 === 0) {\n    evenNums[evenNums.length] = nums[i];\n  } else {\n    oddNums[oddNums.length] = nums[i];\n  }\n}\n\nlet result = {\n  \"odd\": oddNums,\n  \"even\": evenNums\n};\n\nconsole.log(result);\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nShow Chess board in javascript and make it to center.\n\n```javascript\nconst chessboard = document.createElement(\"div\");\nchessboard.id = \"chessboard\";\nchessboard.style.display = \"flex\";\nchessboard.style.flexDirection = \"column\";\nchessboard.style.justifyContent = \"center\";\nchessboard.style.alignItems = \"center\";\nchessboard.style.height = \"450px\";\n\nfor (let i = 0; i \u003c 8; i++) {\n  const row = document.createElement(\"div\");\n  row.style.display = \"flex\";\n  \n  for (let j = 0; j \u003c 8; j++) {\n    const cell = document.createElement(\"div\");\n    cell.style.width = \"50px\";\n    cell.style.height = \"50px\";\n    cell.style.backgroundColor = (i + j) % 2 === 0 ? \"white\" : \"black\";\n    cell.style.border = \"1px solid black\";\n    row.appendChild(cell);\n  }\n  \n  chessboard.appendChild(row);\n}\n\ndocument.body.appendChild(chessboard);\n```\n\nPrint the result for the code below\n\n```javascript\nvar obj1 = {\n  num: 10\n}\nvar obj2 = Object.create(obj1); \nconsole.log(obj2.num);\n\n// output: 10\n```\n\nPrint the result for the code below\n\n```javascript\nvar num = 10; \nvar obj = {\n  num: 20\n}; \n(function() {\n  console.log(num, obj.num);\n})();\n\n// output: 10 20\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nPrint the result for the code below\n\n```javascript\nvar num1 = 20;\nvar num2 = 30;\n[num1, num2] [num2, num1];\nconsole.log(num1, num2);\n\n// output: 20 30 \n```\n\nPrint the result for the code below\n\n```javascript\nvar num= 10;\nvar obj = {\n    num: 20,\n    printNum: function() {\n      console.log(this.num);\n  }\n};\nvar newObj = obj.printNum.bind(obj);\nnewObj();\n\n// output: 20\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nPrint the result for the code below\n\n```javascript\nvar num= 10;\nvar obj = {\n  num: 20,\n  printNum: function() { \n    console.log(this.num);\n  }\n}; \nvar newObj = obj.printNum.bind({ num: 30 });\nnewObj();\n\n//  output: 30\n```\n\nPrint the result for the code below\n\n```javascript\nvar person = { \n  name: \"John\",\n  greet: function() { \n    console.log(\"Hello, my name is \"+this.name); \n  }\n}\nvar newPerson = person;\nnewPerson.name = \"Jane\";\nperson.greet();\n\n// output: Hello, my name is Jane\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nPrint the result for the code below\n\n```javascript\nvar num = 10;\nvar obj = {\n  num: 20\n};\n(function(num, obj) { \n  console.log(num, obj.num); \n})(num, obj);\n\n// output: 10 20\n```\n\nPrint the result for the code below\n\n```javascript\nvar num = 10; \nvar obj = {\n  num: 20,\n  printNum: function() { \n    console.log(this.num); \n  }\n};\nvar newObj = obj.printNum; \nnewObj();\n\n// output: 10\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nWrite a JavaScript program to remove duplicate items from an array.\n\n```javascript\nlet arr = ['CS001', 'TSW002','STS003','CS001','TSW002','STS004'];\n\n// using built-in Set\nlet arr = ['CS001', 'TSW002','STS003','CS001','TSW002','STS004'];\nlet uniqueArr = [...new Set(arr)];\nconsole.log(uniqueArr); // Output: ['CS001', 'TSW002', 'STS003', 'STS004']\n\n// using filter\nlet arr = ['CS001', 'TSW002','STS003','CS001','TSW002','STS004'];\nlet uniqueArr = arr.filter((item, index) =\u003e arr.indexOf(item) === index);\nconsole.log(uniqueArr); // Output: ['CS001', 'TSW002', 'STS003', 'STS004']\n\n// using reduce\nlet arr = ['CS001', 'TSW002','STS003','CS001','TSW002','STS004'];\nlet uniqueArr = arr.reduce((acc, item) =\u003e {\n  if (!acc.includes(item)) {\n    acc.push(item);\n  }\n  return acc;\n}, []);\nconsole.log(uniqueArr); // Output: ['CS001', 'TSW002', 'STS003', 'STS004']\n\n// using forEach\nlet arr = ['CS001', 'TSW002','STS003','CS001','TSW002','STS004'];\nlet uniqueArr = [];\narr.forEach((item) =\u003e {\n  if (!uniqueArr.includes(item)) {\n    uniqueArr.push(item);\n  }\n});\nconsole.log(uniqueArr); // Output: ['CS001', 'TSW002', 'STS003', 'STS004']\n\n// using indexOf\nlet arr = ['CS001', 'TSW002','STS003','CS001','TSW002','STS004'];\nlet uniqueArr = [];\nfor (let i = 0; i \u003c arr.length; i++) {\n  if (uniqueArr.indexOf(arr[i]) === -1) {\n    uniqueArr.push(arr[i]);\n  }\n}\nconsole.log(uniqueArr); // Output: ['CS001', 'TSW002', 'STS003', 'STS004']\n\n// using includes\nlet arr = ['CS001', 'TSW002','STS003','CS001','TSW002','STS004'];\nlet uniqueArr = [];\nfor (let i = 0; i \u003c arr.length; i++) {\n  if (!uniqueArr.includes(arr[i])) {\n    uniqueArr.push(arr[i]);\n  }\n}\n\nconsole.log(uniqueArr); // Output: ['CS001', 'TSW002', 'STS003', 'STS004']\n\n// using map\nlet arr = ['CS001', 'TSW002','STS003','CS001','TSW002','STS004'];\nlet uniqueArr = [];\narr.map((item) =\u003e {\n  if (!uniqueArr.includes(item)) {\n    uniqueArr.push(item);\n  }\n});\nconsole.log(uniqueArr); // Output: ['CS001', 'TSW002', 'STS003', 'STS004']\n\n// using while loop\nlet arr = ['CS001', 'TSW002','STS003','CS001','TSW002','STS004'];\nlet uniqueArr = [];\nlet i = 0;\nwhile (i \u003c arr.length) {\n  if (!uniqueArr.includes(arr[i])) {\n    uniqueArr.push(arr[i]);\n  }\n  i++;\n}\nconsole.log(uniqueArr); // Output: ['CS001', 'TSW002', 'STS003', 'STS004']\n\n// using without built-in methods\nlet arr = ['CS001', 'TSW002','STS003','CS001','TSW002','STS004'];\nlet uniqueArr = [];\nfor (let i = 0; i \u003c arr.length; i++) {\n  let isUnique = true;\n  for (let j = 0; j \u003c uniqueArr.length; j++) {\n    if (arr[i] === uniqueArr[j]) {\n      isUnique = false;\n      break;\n    }\n  }\n  if (isUnique) {\n    uniqueArr.push(arr[i]);\n  }\n}\nconsole.log(uniqueArr); // Output: ['CS001', 'TSW002', 'STS003', 'STS004']\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nWrite a JavaScript program to find 'CS001' in the array.\n\n```javascript\nlet arr = ['CS001', 'TSW002','STS003','CS001','TSW002','STS004'];\n\n// using built-in method find\nlet arr = ['CS001', 'TSW002','STS003','CS001','TSW002','STS004'];\nlet index = arr.find((item) =\u003e item === 'TSW002');\nconsole.log(index); // Output: TSW002\n\n// using without built-in methods or functions\nlet arr = ['CS001', 'TSW002','STS003','CS001','TSW002','STS004'];\nlet index = -1;\nfor (let i = 0; i \u003c arr.length; i++) {\n  if (arr[i] === 'TSW002') {\n    index = i;\n    break;\n  }\n}\nconsole.log(index); // Output: 1\nconsole.log(arr[index]); // Output: TSW002\n```\n\nWrite a JavaScript program to find middle element of an array.\n\n```javascript\nlet arr = ['CS001', 'TSW002','STS003','CS001','TSW002'];\n\n// using built-in method slice\nlet arr = ['CS001', 'TSW002','STS003','CS001','TSW002'];\nlet middle = arr.slice(Math.floor(arr.length / 2), Math.ceil(arr.length / 2) + 1);\nconsole.log(middle); // Output: ['STS003']\n\n// using without built-in methods or functions\nlet arr = ['CS001', 'TSW002','STS003','CS001','TSW002'];\nlet middle = [];\nif (arr.length % 2 === 0) {\n  middle = [arr[arr.length / 2 - 1], arr[arr.length / 2]];\n} else {\n  middle = [arr[(arr.length - 1) / 2]];\n}\nconsole.log(middle); // Output: ['STS003']\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nWrite a JavaScript program to find last element of an array.\n\n```javascript\nlet arr = ['CS001', 'TSW002','STS003','CS001','TSW002','STS004'];\n\n// using built-in method or function\nlet arr = ['CS001', 'TSW002','STS003','CS001','TSW002','STS004'];\nlet last = arr[arr.length - 1];\nconsole.log(last); // Output: STS004\n\n// using without built-in methods or functions\nlet arr = ['CS001', 'TSW002','STS003','CS001','TSW002','STS004'];\nfor (let i = 0; i \u003c arr.length; i++) {\n  if (i === arr.length - 1) {\n    console.log(arr[i]); // Output: STS004\n  }\n}\n```\n\nGive the output for the code below\n\n```javascript\nfunction counter() {\n    let count = 0;\n    return () =\u003e count++;\n}\n\nlet c = counter();\nconsole.log(\"count1\", c()); // Output: 0\nconsole.log(\"count2\", c()); // Output: 1\nconsole.log(\"count3\", c()); // Output: 2\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram To Print Hello World\n\n```javascript\nconsole.log(\"Hello, World!\");\n\n// Output: Hello, World!\n```\n\nProgram to Add Two Numbers\n\n```javascript\nconst num1 = 5;\nconst num2 = 10;\nconst sum = num1 + num2;\n\nconsole.log(\"The sum of \" + num1 + \" and \" + num2 + \" is: \" + sum);\n\n// Output: The sum of 5 and 10 is: 15\n```\n\nProgram to Find the Square Root\n\n```javascript\nconst num = 16;\nconst squareRoot = Math.sqrt(num);\n\nconsole.log(\"The square root of \" + num + \" is: \" + squareRoot);\n\n// Output: The square root of 16 is: 4\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Calculate the Area of a Triangle\n\n```javascript\nconst base = 5;\nconst height = 10;\nconst area = 0.5 * base * height;\n\nconsole.log(\"The area of the triangle is: \" + area);\n\n// Output: The area of the triangle is: 25\n```\n\nProgram to Swap Two Variables\n\n```javascript\nlet a = 5;\nlet b = 10;\n\n[a, b] = [b, a];\n\nconsole.log(\"a is: \" + a);\nconsole.log(\"b is: \" + b);\n\n// Output: a is: 10\n// Output: b is: 5\n```\n\nProgram to Solve Quadratic Equation\n\n```javascript\nconst a = 1;\nconst b = 5;\nconst c = 6;\n\nconst discriminant = b * b - 4 * a * c;\n\nlet x1, x2;\n\nif (discriminant \u003e 0) {\n  x1 = (-b + Math.sqrt(discriminant)) / (2 * a);\n  x2 = (-b - Math.sqrt(discriminant)) / (2 * a);\n  console.log(\"The roots are: \" + x1 + \" and \" + x2);\n} else if (discriminant === 0) {\n  x1 = -b / (2 * a);\n  console.log(\"The root is: \" + x1);\n} else {\n  const realPart = (-b / (2 * a)).toFixed(2);\n  const imaginaryPart = (Math.sqrt(-discriminant) / (2 * a)).toFixed(2);\n  console.log(\"The roots are: \" + realPart + \" + \" + imaginaryPart + \"i and \" + realPart + \" - \" + imaginaryPart + \"i\");\n}\n\n// Output: The roots are: -2 and -3\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Convert Kilometers to Miles\n\n```javascript\nconst kilometers = 5;\nconst miles = kilometers * 0.621371;\n\nconsole.log(kilometers + \" kilometers is equal to \" + miles + \" miles\");\n\n// Output: 5 kilometers is equal to 3.10686 miles\n```\n\nProgram to Convert Celsius to Fahrenheit\n\n```javascript\nconst celsius = 37;\nconst fahrenheit = (celsius * 9 / 5) + 32;\n\nconsole.log(celsius + \"°C is equal to \" + fahrenheit + \"°F\");\n\n// Output: 37°C is equal to 98.6°F\n```\n\nProgram to Generate a Random Number\n\n```javascript\nconst min = 1;\nconst max = 10;\nconst randomNum = Math.floor(Math.random() * (max - min + 1)) + min;\n\nconsole.log(\"Random number between \" + min + \" and \" + max + \" is: \" + randomNum);\n\n// Output: Random number between 1 and 10 is: 7\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Check if a number is Positive, Negative, or Zero\n\n```javascript\nconst num = 5;\n\nif (num \u003e 0) {\n  console.log(num + \" is a positive number\");\n} else if (num \u003c 0) {\n  console.log(num + \" is a negative number\");\n} else {\n  console.log(num + \" is zero\");\n}\n\n// Output: 5 is a positive number\n```\n\nProgram to Check if a Number is Odd or Even\n\n```javascript\nconst num = 5;\n\nif (num % 2 === 0) {\n  console.log(num + \" is an even number\");\n} else {\n  console.log(num + \" is an odd number\");\n}\n\n// Output: 5 is an odd number\n```\n\nProgram to Find the Largest Among Three Numbers\n\n```javascript\nconst num1 = 10;\nconst num2 = 20;\nconst num3 = 15;\n\nlet largest;\n\nif (num1 \u003e= num2 \u0026\u0026 num1 \u003e= num3) {\n  largest = num1;\n} else if (num2 \u003e= num1 \u0026\u0026 num2 \u003e= num3) {\n  largest = num2;\n} else {\n  largest = num3;\n}\n\nconsole.log(\"The largest number is: \" + largest);\n\n// Output: The largest number is: 20\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Check Prime Number\n\n```javascript\nconst num = 29;\nlet isPrime = true;\n\nif (num === 1) {\n  console.log(\"1 is neither prime nor composite number.\");\n} else if (num \u003e 1) {\n  for (let i = 2; i \u003c num; i++) {\n    if (num % i === 0) {\n      isPrime = false;\n      break;\n    }\n  }\n\n  if (isPrime) {\n    console.log(num + \" is a prime number\");\n  } else {\n    console.log(num + \" is not a prime number\");\n  }\n} else {\n  console.log(\"Invalid input\");\n}\n\n// Output: 29 is a prime number\n```\n\nProgram to Print All Prime Numbers in an Interval\n\n```javascript\nconst lowerNumber = 10;\nconst upperNumber = 50;\n\nconsole.log(\"Prime numbers between \" + lowerNumber + \" and \" + upperNumber + \" are:\");\n\nfor (let i = lowerNumber; i \u003c= upperNumber; i++) {\n  let isPrime = true;\n\n  if (i === 1) {\n    isPrime = false;\n  } else if (i \u003e 1) {\n    for (let j = 2; j \u003c i; j++) {\n      if (i % j === 0) {\n        isPrime = false;\n        break;\n      }\n    }\n  }\n\n  if (isPrime) {\n    console.log(i);\n  }\n}\n\n// Output: Prime numbers between 10 and 50 are:\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Find the Factorial of a Number\n\n```javascript\nconst num = 5;\nlet factorial = 1;\n\nif (num \u003c 0) {\n  console.log(\"Factorial of a negative number is not possible\");\n} else {\n  for (let i = 1; i \u003c= num; i++) {\n    factorial *= i;\n  }\n  console.log(\"The factorial of \" + num + \" is: \" + factorial);\n}\n\n// Output: The factorial of 5 is: 120\n```\n\nProgram to Display the Multiplication Table\n\n```javascript\nconst num = 5;\n\nconsole.log(\"Multiplication table of \" + num + \":\");\n\nfor (let i = 1; i \u003c= 10; i++) {\n  console.log(num + \" * \" + i + \" = \" + num * i);\n}\n\n// Output: Multiplication table of 5:\n```\n\nProgram to Print the Fibonacci Sequence\n\n```javascript\nconst num = 10;\nlet n1 = 0, n2 = 1, nextTerm;\n\nconsole.log(\"Fibonacci series up to \" + num + \" terms:\");\n\nfor (let i = 1; i \u003c= num; i++) {\n  console.log(n1);\n  nextTerm = n1 + n2;\n  n1 = n2;\n  n2 = nextTerm;\n}\n\n// Output: Fibonacci series up to 10 terms: 0 1 1 2 3 5 8 13 21 34\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Check Armstrong Number\n\n```javascript\nconst num = 153;\nlet sum = 0;\nlet temp = num;\nlet remainder;\n\nwhile (temp \u003e 0) {\n  remainder = temp % 10;\n  sum += remainder * remainder * remainder;\n  temp = parseInt(temp / 10);\n}\n\nif (sum === num) {\n  console.log(num + \" is an Armstrong number\");\n} else {\n  console.log(num + \" is not an Armstrong number\");\n}\n\n// Output: 153 is an Armstrong number\n```\n\nProgram to Find Armstrong Number in an Interval\n\n```javascript\nconst lowerNumber = 100;\nconst upperNumber = 1000;\n\nconsole.log(\"Armstrong numbers between \" + lowerNumber + \" and \" + upperNumber + \" are:\");\n\nfor (let i = lowerNumber; i \u003c= upperNumber; i++) {\n  let numberOfDigits = i.toString().length;\n  let sum = 0;\n  let temp = i;\n  let remainder;\n\n  while (temp \u003e 0) {\n    remainder = temp % 10;\n    sum += remainder ** numberOfDigits;\n    temp = parseInt(temp / 10);\n  }\n\n  if (sum === i) {\n    console.log(i);\n  }\n}\n\n// Output: Armstrong numbers between 100 and 1000 are: 153 370 371 407\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Make a Simple Calculator\n\n```javascript\nconst operator = '+';\nconst num1 = 5;\nconst num2 = 10;\nlet result;\n\nswitch (operator) {\n  case '+':\n    result = num1 + num2;\n    break;\n  case '-':\n    result = num1 - num2;\n    break;\n  case '*':\n    result = num1 * num2;\n    break;\n  case '/':\n    result = num1 / num2;\n    break;\n  default:\n    console.log(\"Invalid operator\");\n}\n\nconsole.log(\"The result is: \" + result); // Output: The result is: 15\n```\n\nProgram to Find the Sum of Natural Numbers\n\n```javascript\nconst num = 10;\nlet sum = 0;\n\nfor (let i = 1; i \u003c= num; i++) {\n  sum += i;\n}\n\nconsole.log(\"The sum of natural numbers up to \" + num + \" is: \" + sum);\n\n// Output: The sum of natural numbers up to 10 is: 55\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Check if the Numbers Have Same Last Digit\n\n```javascript\nconst num1 = 25;\nconst num2 = 35;\n\nif (num1 % 10 === num2 % 10) {\n  console.log(\"Both numbers have the same last digit\");\n} else {\n  console.log(\"Both numbers do not have the same last digit\");\n}\n\n// Output: Both numbers have the same last digit\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Find HCF or GCD\n\n```javascript\nconst num1 = 12;\nconst num2 = 18;\nlet hcf;\n\nfor (let i = 1; i \u003c= num1 \u0026\u0026 i \u003c= num2; i++) {\n  if (num1 % i === 0 \u0026\u0026 num2 % i === 0) {\n    hcf = i;\n  }\n}\n\nconsole.log(\"The HCF of \" + num1 + \" and \" + num2 + \" is: \" + hcf);\n\n// Output: The HCF of 12 and 18 is: 6\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Find LCM\n\n```javascript\nconst num1 = 12;\nconst num2 = 18;\nlet lcm;\n\nlcm = (num1 \u003e num2) ? num1 : num2;\n\nwhile (true) {\n  if (lcm % num1 === 0 \u0026\u0026 lcm % num2 === 0) {\n    console.log(\"The LCM of \" + num1 + \" and \" + num2 + \" is: \" + lcm);\n    break;\n  }\n  lcm++;\n}\n\n// Output: The LCM of 12 and 18 is: 36\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Find the Factors of a Number\n\n```javascript\nconst num = 60;\n\nconsole.log(\"The factors of \" + num + \" are:\");\n\nfor (let i = 1; i \u003c= num; i++) {\n  if (num % i === 0) {\n    console.log(i);\n  }\n}\n\n// Output: The factors of 60 are: 1 2 3 4 5 6 10 12 15 20 30 60\n```\n\nProgram to Find Sum of Natural Numbers Using Recursion\n\n```javascript\nfunction sum(num) {\n  if (num === 1) {\n    return 1;\n  } else {\n    return num + sum(num - 1);\n  }\n}\n\nconst n = 10;\nconst result = sum(n);\n\nconsole.log(\"The sum of natural numbers up to \" + n + \" is: \" + result);\n\n// Output: The sum of natural numbers up to 10 is: 55\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Guess a Random Number\n\n```javascript\nconst min = 1;\nconst max = 10;\nconst randomNum = Math.floor(Math.random() * (max - min + 1)) + min;\nlet guess;\n\ndo {\n  guess = parseInt(prompt(\"Guess a number between \" + min + \" and \" + max));\n  if (guess \u003e randomNum) {\n    console.log(\"Too high. Try again!\");\n  } else if (guess \u003c randomNum) {\n    console.log(\"Too low. Try again!\");\n  }\n} while (guess !== randomNum);\n\nconsole.log(\"Congratulations! You guessed the correct number.\");\n\n// Output: Congratulations! You guessed the correct number.\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Shuffle Deck of Cards\n\n```javascript\nconst suits = [\"Hearts\", \"Diamonds\", \"Clubs\", \"Spades\"];\nconst ranks = [\"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"Jack\", \"Queen\", \"King\", \"Ace\"];\n\nconst deck = [];\n\nfor (const suit of suits) {\n  for (const rank of ranks) {\n    deck.push(rank + \" of \" + suit);\n  }\n}\n\nconsole.log(\"Shuffled deck of cards:\");\nfor (const card of deck) {\n  console.log(card);\n}\n\n// Output: Shuffled deck of cards: 2 of Hearts 3 of Hearts 4 of Hearts ...\n```\n\nProgram to Display Fibonacci Sequence Using Recursion\n\n```javascript\nfunction fibonacci(num) {\n  if (num \u003c= 1) {\n    return num;\n  } else {\n    return fibonacci(num - 1) + fibonacci(num - 2);\n  }\n}\n\nconst n = 10;\n\nconsole.log(\"Fibonacci series up to \" + n + \" terms:\");\n\nfor (let i = 0; i \u003c n; i++) {\n  console.log(fibonacci(i));\n}\n\n// Output: Fibonacci series up to 10 terms: 0 1 1 2 3 5 8 13 21 34\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Find Factorial of Number Using Recursion\n\n```javascript\nfunction factorial(num) {\n  if (num === 0) {\n    return 1;\n  } else {\n    return num * factorial(num - 1);\n  }\n}\n\nconst n = 5;\n\nconsole.log(\"The factorial of \" + n + \" is: \" + factorial(n));\n\n// Output: The factorial of 5 is: 120\n```\n\nProgram to Convert Decimal to Binary\n\n```javascript\nconst decimal = 10;\nlet binary = \"\";\n\nwhile (decimal \u003e 0) {\n  binary = (decimal % 2) + binary;\n  decimal = parseInt(decimal / 2);\n}\n\nconsole.log(\"The binary equivalent is: \" + binary);\n\n// Output: The binary equivalent is: 1010\n```\n\nProgram to Find ASCII Value of Character\n\n```javascript\nconst char = 'A';\n\nconsole.log(\"The ASCII value of \" + char + \" is: \" + char.charCodeAt(0));\n\n// Output: The ASCII value of A is: 65\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Check Whether a String is Palindrome or Not\n\n```javascript\nconst str = \"madam\";\nlet isPalindrome = true;\n\nfor (let i = 0; i \u003c str.length / 2; i++) {\n  if (str[i] !== str[str.length - 1 - i]) {\n    isPalindrome = false;\n    break;\n  }\n}\n\nif (isPalindrome) {\n  console.log(str + \" is a palindrome\");\n} else {\n  console.log(str + \" is not a palindrome\");\n}\n\n// Output: madam is a palindrome\n```\n\nProgram to Sort Words in Alphabetical Order\n\n```javascript\nconst words = [\"Apple\", \"Banana\", \"Orange\", \"Mango\"];\nwords.sort();\n\nconsole.log(\"Words in alphabetical order:\");\n\nfor (const word of words) {\n  console.log(word);\n}\n\n// Output: Words in alphabetical order: Apple Banana Mango Orange\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Replace Characters of a String\n\n```javascript\nconst str = \"Hello, World!\";\n\nconst newStr = str.replace(/o/g, \"x\");\n\nconsole.log(\"Original string: \" + str);\nconsole.log(\"New string: \" + newStr);\n\n// Output: Original string: Hello, World!\n// Output: New string: Hellx, Wxrld!\n```\n\nProgram to Reverse a String\n\n```javascript\nconst str = \"Hello, World!\";\nlet reversedStr = \"\";\n\nfor (let i = str.length - 1; i \u003e= 0; i--) {\n  reversedStr += str[i];\n}\n\nconsole.log(\"Original string: \" + str);\nconsole.log(\"Reversed string: \" + reversedStr);\n\n// Output: Original string: Hello, World!\n// Output: Reversed string: !dlroW ,olleH\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Create Objects in Different Ways\n\n```javascript\n// Using Object Literal\nconst person1 = {\n  name: \"Alice\",\n  age: 30\n};\n\n// Using Object Constructor\nfunction Person(name, age) {\n  this.name = name;\n  this.age = age;\n}\n\nconst person2 = new Person(\"Bob\", 25);\n\n// Using Object.create()\nconst person3 = Object.create(person1);\n\nconsole.log(person1);\n\nconsole.log(person2);\n\nconsole.log(person3);\n\n// Output: { name: 'Alice', age: 30 }\n// Output: Person { name: 'Bob', age: 25 }\n// Output: {}\n```\n\nProgram to Check the Number of Occurrences of a Character in the String\n\n```javascript\nconst str = \"Hello, World!\";\nconst char = \"o\";\n\nlet count = 0;\n\nfor (let i = 0; i \u003c str.length; i++) {\n  if (str[i] === char) {\n    count++;\n  }\n}\n\nconsole.log(\"The number of occurrences of \" + char + \" in the string is: \" + count);\n// Output: The number of occurrences of o in the string is: 2\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Convert the First Letter of a String into UpperCase\n\n```javascript\nconst str = \"hello, world!\";\nconst firstLetter = str[0].toUpperCase();\n\nconst newStr = firstLetter + str.slice(1);\n\nconsole.log(\"Original string: \" + str);\nconsole.log(\"New string: \" + newStr);\n\n// Output: Original string: hello, world!\n// Output: New string: Hello, world!\n```\n\nProgram to Count the Number of Vowels in a String\n\n```javascript\nconst str = \"hello, world!\";\nconst vowels = \"aeiou\";\nlet count = 0;\n\nfor (let char of str) {\n  if (vowels.includes(char.toLowerCase())) {\n    count++;\n  }\n}\n\nconsole.log(\"The number of vowels in the string is: \" + count);\n// Output: The number of vowels in the string is: 3\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Remove a Property from an Object\n\n```javascript\nconst person = {\n  name: \"Alice\",\n  age: 30,\n  profession: \"Developer\"\n};\n\ndelete person.profession;\n\nconsole.log(person);\n// Output: { name: 'Alice', age: 30 }\n```\n\nProgram to Check Whether a String Starts and Ends With Certain Characters\n\n```javascript\nconst str = \"hello, world!\";\nconst startsWith = \"he\";\nconst endsWith = \"ld\";\n\nif (str.startsWith(startsWith) \u0026\u0026 str.endsWith(endsWith)) {\n  console.log(\"The string starts with \" + startsWith + \" and ends with \" + endsWith);\n} else {\n  console.log(\"The string does not start with \" + startsWith + \" and end with \" + endsWith);\n}\n\n// Output: The string starts with he and ends with ld\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Check if a Key Exists in an Object\n\n```javascript\nconst person = {\n  name: \"Alice\",\n  age: 30\n};\n\nconst key = \"name\";\n\nif (key in person) {\n  console.log(\"The key \" + key + \" exists in the object\");\n} else {\n  console.log(\"The key \" + key + \" does not exist in the object\");\n}\n\n// Output: The key name exists in the object\n```\n\nProgram to Clone a JS Object\n\n```javascript\nconst person = {\n  name: \"Alice\",\n  age: 30\n};\n\nconst clone = { ...person };\n\nconsole.log(clone);\n// Output: { name: 'Alice', age: 30 }\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Loop Through an Object\n\n```javascript\nconst person = {\n  name: \"Alice\",\n  age: 30\n};\n\nfor (const key in person) {\n  console.log(key + \": \" + person[key]);\n}\n\n// Output: name: Alice\n```\n\nProgram to Merge Property of Two Objects\n\n```javascript\nconst obj1 = {\n  name: \"Alice\"\n};\n\nconst obj2 = {\n  age: 30\n};\n\nconst mergedObj = { ...obj1, ...obj2 };\n\nconsole.log(mergedObj);\n\n// Output: { name: 'Alice', age: 30 }\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Count the Number of Keys/Properties in an Object\n\n```javascript\nconst person = {\n  name: \"Alice\",\n  age: 30\n};\n\nconst keys = Object.keys(person);\nconst count = keys.length;\n\nconsole.log(\"The number of keys in the object is: \" + count);\n\n// Output: The number of keys in the object is: 2\n```\n\nProgram to Add Key/Value Pair to an Object\n\n```javascript\nconst person = {\n  name: \"Alice\",\n  age: 30\n};\n\nperson.profession = \"Developer\";\n\nconsole.log(person);\n\n// Output: { name: 'Alice', age: 30, profession: 'Developer' }\n```\n\nProgram to Replace All Occurrences of a String\n\n```javascript\nconst str = \"hello, world!\";\nconst newStr = str.replace(/l/g, \"x\");\n\nconsole.log(\"Original string: \" + str);\n\nconsole.log(\"New string: \" + newStr);\n\n// Output: Original string: hello, world!\n// Output: New string: hexxo, worxd!\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Create Multiline Strings\n\n```javascript\nconst multilineString = `This is a\nmultiline\nstring`;\n\nconsole.log(multilineString);\n\n// Output: This is a\n// multiline\n// string\n```\n\nProgram to Format Numbers as Currency Strings\n\n```javascript\nconst number = 12345.6789;\n\nconst currencyString = number.toLocaleString('en-US', { style: 'currency', currency: 'USD' });\n\nconsole.log(currencyString);\n\n// Output: $12,345.68\n```\n\nProgram to Generate Random String\n\n```javascript\nconst randomString = Math.random().toString(36).substring(7);\n\nconsole.log(randomString);\n\n// Output: Random string of length 7 characters (e.g., \"x8z2j9a\")\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Check if a String Starts With Another String\n\n```javascript\nconst str = \"hello, world!\";\nconst startsWith = \"hello\";\n\nif (str.startsWith(startsWith)) {\n  console.log(\"The string starts with \" + startsWith);\n} else {\n  console.log(\"The string does not start with \" + startsWith);\n}\n\n// Output: The string starts with hello\n```\n\nProgram to Trim a String\n\n```javascript\nconst str = \"   hello, world!   \";\nconst trimmedStr = str.trim();\n\nconsole.log(\"Original string: \" + str);\n\nconsole.log(\"Trimmed string: \" + trimmedStr);\n\n// Output: Original string:    hello, world!\n// Output: Trimmed string: hello, world!\n```\n\nProgram to Convert Objects to Strings\n\n```javascript\nconst person = {\n  name: \"Alice\",\n  age: 30\n};\n\nconst str = JSON.stringify(person);\n\nconsole.log(str);\n\n// Output: {\"name\":\"Alice\",\"age\":30}\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Check Whether a String Contains a Substring\n\n```javascript\nconst str = \"hello, world!\";\nconst subStr = \"world\";\n\nif (str.includes(subStr)) {\n  console.log(\"The string contains \" + subStr);\n} else {\n  console.log(\"The string does not contain \" + subStr);\n}\n\n// Output: The string contains world\n```\n\nProgram to Compare Two Strings\n\n```javascript\nconst str1 = \"hello\";\nconst str2 = \"world\";\n\nif (str1 === str2) {\n  console.log(\"The strings are equal\");\n} else {\n  console.log(\"The strings are not equal\");\n}\n\n// Output: The strings are not equal\n```\n\nProgram to Encode a String to Base64\n\n```javascript\nconst str = \"hello, world!\";\nconst encodedStr = btoa(str);\n\nconsole.log(\"Encoded string: \" + encodedStr);\n// Output: Encoded string: aGVsbG8sIHdvcmxkIQ==\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Replace all Instances of a Character in a String\n\n```javascript\nconst str = \"hello, world!\";\nconst newStr = str.replace(/l/g, \"x\");\n\nconsole.log(\"Original string: \" + str);\nconsole.log(\"New string: \" + newStr);\n\n// Output: Original string: hello, world!\n// Output: New string: hexxo, worxd!\n```\n\nProgram to Replace All Line Breaks with\n\n```javascript\nconst str = \"hello\\nworld!\";\nconst newStr = str.replace(/\\n/g, \" \");\n\nconsole.log(\"Original string: \" + str);\nconsole.log(\"New string: \" + newStr);\n\n// Output: Original string: hello\n// world!\n// Output: New string: hello world!\n```\n\nProgram to Display Date and Time\n\n```javascript\nconst date = new Date();\n\nconsole.log(\"Current date and time: \" + date);\n// Output: Current date and time: Sun Oct 31 2021 12:00:00 GMT+0530 (India Standard Time)\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Check Leap Year\n\n```javascript\nconst year = 2024;\n\nif ((year % 4 === 0 \u0026\u0026 year % 100 !== 0) || year % 400 === 0) {\n  console.log(year + \" is a leap year\");\n} else {\n  console.log(year + \" is not a leap year\");\n}\n\n// Output: 2024 is a leap year\n```\n\nProgram to Format the Date\n\n```javascript\nconst date = new Date();\n\nconst options = { year: 'numeric', month: 'long', day: 'numeric' };\n\nconst formattedDate = date.toLocaleDateString('en-US', options);\n\nconsole.log(\"Formatted date: \" + formattedDate);\n// Output: Formatted date: October 31, 2021\n```\n\nProgram to Display Current Date\n\n```javascript\nconst date = new Date();\n\nconst day = date.getDate();\n\nconst month = date.getMonth() + 1;\n\nconst year = date.getFullYear();\n\nconsole.log(\"Current date: \" + day + \"/\" + month + \"/\" + year);\n// Output: Current date: 14/06/2024\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Compare The Value of Two Dates\n\n```javascript\nconst date1 = new Date('2021-10-31');\nconst date2 = new Date('2021-11-01');\n\nif (date1 \u003e date2) {\n  console.log(\"Date 1 is greater than Date 2\");\n} else if (date1 \u003c date2) {\n  console.log(\"Date 1 is less than Date 2\");\n} else {\n  console.log(\"Date 1 is equal to Date 2\");\n}\n\n// Output: Date 1 is less than Date 2\n```\n\nProgram to Create Countdown Timer\n\n```javascript\nlet count = 10;\n\nconst interval = setInterval(() =\u003e {\n  console.log(count);\n  count--;\n\n  if (count \u003c 0) {\n    clearInterval(interval);\n    console.log(\"Countdown is over\");\n  }\n}, 1000);\n\n// Output: 10 9 8 7 6 5 4 3 2 1 0 Countdown is over\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Remove Specific Item From an Array\n\n```javascript\nconst fruits = [\"Apple\", \"Banana\", \"Orange\", \"Mango\"];\n\nconst index = fruits.indexOf(\"Banana\");\n\nif (index \u003e -1) {\n  fruits.splice(index, 1);\n}\n\nconsole.log(fruits);\n// Output: [\"Apple\", \"Orange\", \"Mango\"]\n```\n\nProgram to Check if An Array Contains a Specified Value\n\n```javascript\nconst fruits = [\"Apple\", \"Banana\", \"Orange\", \"Mango\"];\n\nconst value = \"Banana\";\n\nif (fruits.includes(value)) {\n  console.log(\"The array contains \" + value);\n} else {\n  console.log(\"The array does not contain \" + value);\n}\n\n// Output: The array contains Banana\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Insert Item in an Array\n\n```javascript\nconst fruits = [\"Apple\", \"Banana\", \"Orange\", \"Mango\"];\n\nfruits.push(\"Grapes\");\n\nconsole.log(fruits);\n// Output: [\"Apple\", \"Banana\", \"Orange\", \"Mango\", \"Grapes\"]\n```\n\nProgram to Append an Object to an Array\n\n```javascript\nconst fruits = [\"Apple\", \"Banana\", \"Orange\", \"Mango\"];\n\nconst obj = { name: \"Grapes\" };\n\nfruits.push(obj);\n\nconsole.log(fruits);\n// Output: [\"Apple\", \"Banana\", \"Orange\", \"Mango\", { name: 'Grapes' }]\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Check if An Object is An Array\n\n```javascript\nconst fruits = [\"Apple\", \"Banana\", \"Orange\", \"Mango\"];\n\nif (Array.isArray(fruits)) {\n  console.log(\"fruits is an array\");\n} else {\n  console.log(\"fruits is not an array\");\n}\n\n// Output: fruits is an array\n```\n\nProgram to Empty an Array\n\n```javascript\nlet fruits = [\"Apple\", \"Banana\", \"Orange\", \"Mango\"];\n\nfruits = [];\n\nconsole.log(fruits);\n\n// Output: []\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Add Element to Start of an Array\n\n```javascript\nlet fruits = [\"Apple\", \"Banana\", \"Orange\", \"Mango\"];\n\nfruits.unshift(\"Grapes\");\n\nconsole.log(fruits);\n// Output: [\"Grapes\", \"Apple\", \"Banana\", \"Orange\", \"Mango\"]\n```\n\nProgram to Remove Duplicates From Array\n\n```javascript\nconst fruits = [\"Apple\", \"Banana\", \"Orange\", \"Mango\", \"Apple\", \"Banana\"];\n\nconst uniqueFruits = [...new Set(fruits)];\n\nconsole.log(uniqueFruits);\n// Output: [\"Apple\", \"Banana\", \"Orange\", \"Mango\"]\n```\n\nProgram to Merge Two Arrays and Remove Duplicate Items\n\n```javascript\nconst arr1 = [1, 2, 3];\nconst arr2 = [3, 4, 5];\n\nconst mergedArray = [...new Set([...arr1, ...arr2])];\n\nconsole.log(mergedArray);\n// Output: [1, 2, 3, 4, 5]\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Sort Array of Objects by Property Values\n\n```javascript\nconst persons = [\n  { name: \"Alice\", age: 30 },\n  { name: \"Bob\", age: 25 },\n  { name: \"Charlie\", age: 35 }\n];\n\npersons.sort((a, b) =\u003e a.age - b.age);\n\nconsole.log(persons);\n// Output: [ { name: 'Bob', age: 25 }, { name: 'Alice', age: 30 }, { name: 'Charlie', age: 35 } ]\n```\n\nProgram to Create Two Dimensional Array\n\n```javascript\nconst matrix = [\n  [1, 2, 3],\n  [4, 5, 6],\n  [7, 8, 9]\n];\n\nconsole.log(matrix);\n// Output: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ]\n```\n\nProgram to Extract Given Property Values from Objects as Array\n\n```javascript\nconst persons = [\n  { name: \"Alice\", age: 30 },\n  { name: \"Bob\", age: 25 },\n  { name: \"Charlie\", age: 35 }\n];\n\nconst names = persons.map(person =\u003e person.name);\n\nconsole.log(names);\n// Output: [ 'Alice', 'Bob', 'Charlie' ]\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Compare Elements of Two Arrays\n\n```javascript\nconst arr1 = [1, 2, 3];\nconst arr2 = [1, 2, 3];\n\nconst isEqual = arr1.length === arr2.length \u0026\u0026 arr1.every((value, index) =\u003e value === arr2[index]);\n\nif (isEqual) {\n  console.log(\"The arrays are equal\");\n} else {\n  console.log(\"The arrays are not equal\");\n}\n\n// Output: The arrays are equal\n```\n\nProgram to Get Random Item From an Array\n\n```javascript\nconst fruits = [\"Apple\", \"Banana\", \"Orange\", \"Mango\"];\n\nconst randomFruit = fruits[Math.floor(Math.random() * fruits.length)];\n\nconsole.log(\"Random fruit: \" + randomFruit);\n// Output: Random fruit: Banana\n```\n\nProgram To Perform Intersection Between Two Arrays\n\n```javascript\nconst arr1 = [1, 2, 3, 4, 5];\nconst arr2 = [3, 4, 5, 6, 7];\n\nconst intersection = arr1.filter(value =\u003e arr2.includes(value));\n\nconsole.log(intersection);\n// Output: [3, 4, 5]\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Split Array into Smaller Chunks\n\n```javascript\nconst arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\nconst chunkSize = 3;\nconst chunks = [];\n\nfor (let i = 0; i \u003c arr.length; i += chunkSize) {\n  chunks.push(arr.slice(i, i + chunkSize));\n}\n\nconsole.log(chunks);\n// Output: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ], [ 10 ] ]\n```\n\nProgram to Include a JS file in Another JS file\n\n```javascript\n// index.js\nconsole.log(\"Hello, World!\");\n\n// script.js\ndocument.write(\"This is a script file\");\n\n// index.html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n  \u003ctitle\u003eInclude JS File\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003cscript src=\"index.js\"\u003e\u003c/script\u003e\n  \u003cscript src=\"script.js\"\u003e\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n\n// Output: In console: Hello, World! In body: This is a script file\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Get File Extension\n\n```javascript\nconst filename = \"script.js\";\nconst extension = filename.split('.').pop();\n\nconsole.log(\"File extension: \" + extension);\n\n// Output: File extension: js\n```\n\nProgram To Check If A Variable Is undefined or null\n\n```javascript\nlet x;\n\nif (x === undefined) {\n  console.log(\"x is undefined\");\n} else {\n  console.log(\"x is defined\");\n}\n\n// Output: x is undefined\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Set a Default Parameter Value For a Function\n\n```javascript\nfunction greet(name = \"World\") {\n  console.log(\"Hello, \" + name + \"!\");\n}\n\ngreet(\"Alice\");\n\ngreet();\n\n// Output: Hello, Alice! Hello, World!\n```\n\nProgram to Illustrate Different Set Operations\n\n```javascript\nconst set1 = new Set([1, 2, 3, 4, 5]);\nconst set2 = new Set([4, 5, 6, 7, 8]);\n\nconst union = new Set([...set1, ...set2]);\nconst intersection = new Set([...set1].filter(x =\u003e set2.has(x)));\n\nconsole.log(\"Union: \" + [...union]);\nconsole.log(\"Intersection: \" + [...intersection]);\n// Output: Union: 1,2,3,4,5,6,7,8 Intersection: 4,5\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Generate a Random Number Between Two Numbers\n\n```javascript\nconst min = 1;\nconst max = 10;\n\nconst randomNum = Math.floor(Math.random() * (max - min + 1)) + min;\n\nconsole.log(\"Random number between \" + min + \" and \" + max + \": \" + randomNum);\n// Output: Random number between 1 and 10: 7\n```\n\nProgram To Get The Current URL\n\n```javascript\nconst currentURL = window.location.href;\n\nconsole.log(\"Current URL: \" + currentURL);\n// Output: Current URL: https://www.example.com/page\n```\n\nProgram to Validate An Email Address\n\n```javascript\nconst email = \"manthan.ank46@gmail.com\";\nconst pattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$/;\n\nif (pattern.test(email)) {\n  console.log(email + \" is a valid email address\");\n} else {\n  console.log(email + \" is not a valid email address\");\n}\n\n// Output: manthan.ank46@gmail.com is a valid email address\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Check If a Variable is of Function Type\n\n```javascript\nfunction greet() {\n  console.log(\"Hello, World!\");\n}\n\nconst x = 10;\n\nif (typeof greet === 'function') {\n  console.log(\"greet is a function\");\n} else {\n  console.log(\"greet is not a function\");\n}\n\nif (typeof x === 'function') {\n  console.log(\"x is a function\");\n} else {\n  console.log(\"x is not a function\");\n}\n\n// Output: greet is a function x is not a function\n```\n\nProgram To Work With Constants\n\n```javascript\nconst PI = 3.14159;\n\nconsole.log(\"The value of PI is: \" + PI);\n// Output: The value of PI is: 3.14159\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Pass Parameter to a setTimeout() Function\n\n```javascript\nfunction greet(name) {\n  console.log(\"Hello, \" + name + \"!\");\n}\n\nsetTimeout(greet, 1000, \"Alice\");\n// Output: Hello, Alice! (after 1 second)\n```\n\nProgram to Generate a Range of Numbers and Characters\n\n```javascript\nconst numbers = Array.from({ length: 10 }, (_, i) =\u003e i + 1);\nconst characters = Array.from({ length: 26 }, (_, i) =\u003e String.fromCharCode(65 + i));\n\nconsole.log(\"Numbers: \" + numbers);\nconsole.log(\"Characters: \" + characters);\n// Output: Numbers: 1,2,3,4,5,6,7,8,9,10 Characters: A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z\n```\n\nProgram to Perform Function Overloading\n\n```javascript\nfunction add(x, y) {\n  return x + y;\n}\n\nfunction add(x, y, z) {\n  return x + y + z;\n}\n\nconsole.log(add(1, 2)); // Output: NaN\nconsole.log(add(1, 2, 3)); // Output: 6\n\n// Explanation: The second function definition overwrites the first one, resulting in the first function call returning NaN.\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Implement a Stack\n\n```javascript\nclass Stack {\n  constructor() {\n    this.items = [];\n  }\n\n  push(element) {\n    this.items.push(element);\n  }\n\n  pop() {\n    if (this.items.length === 0) {\n      return \"Underflow\";\n    }\n    return this.items.pop();\n  }\n\n  peek() {\n    return this.items[this.items.length - 1];\n  }\n\n  isEmpty() {\n    return this.items.length === 0;\n  }\n\n  printStack() {\n    let str = \"\";\n    for (let i = 0; i \u003c this.items.length; i++) {\n      str += this.items[i] + \" \";\n    }\n    return str;\n  }\n}\n\nconst stack = new Stack();\n\nstack.push(1);\n\nstack.push(2);\n\nstack.push(3);\n\nconsole.log(stack.printStack()); // Output: 1 2 3\n\nconsole.log(stack.peek()); // Output: 3\n\nconsole.log(stack.pop()); // Output: 3\n\nconsole.log(stack.printStack()); // Output: 1 2\n\nconsole.log(stack.isEmpty()); // Output: false\n\nstack.pop();\n\nstack.pop();\n\nconsole.log(stack.isEmpty()); // Output: true\n\nconsole.log(stack.pop()); // Output: Underflow\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Implement a Queue\n\n```javascript\nclass Queue {\n  constructor() {\n    this.items = [];\n  }\n\n  enqueue(element) {\n    this.items.push(element);\n  }\n\n  dequeue() {\n    if (this.items.length === 0) {\n      return \"Underflow\";\n    }\n    return this.items.shift();\n  }\n\n  front() {\n    if (this.items.length === 0) {\n      return \"No elements in Queue\";\n    }\n    return this.items[0];\n  }\n\n  isEmpty() {\n    return this.items.length === 0;\n  }\n\n  printQueue() {\n    let str = \"\";\n    for (let i = 0; i \u003c this.items.length; i++) {\n      str += this.items[i] + \" \";\n    }\n    return str;\n  }\n}\n\nconst queue = new Queue();\n\nqueue.enqueue(1);\n\nqueue.enqueue(2);\n\nqueue.enqueue(3);\n\nconsole.log(queue.printQueue()); // Output: 1 2 3\n\nconsole.log(queue.front()); // Output: 1\n\nconsole.log(queue.dequeue()); // Output: 1\n\nconsole.log(queue.printQueue()); // Output: 2 3\n\nconsole.log(queue.isEmpty()); // Output: false\n\nqueue.dequeue();\n\nqueue.dequeue();\n\nconsole.log(queue.isEmpty()); // Output: true\n\nconsole.log(queue.dequeue()); // Output: Underflow\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Check if a Number is Float or Integer\n\n```javascript\nfunction isFloat(num) {\n  return Number(num) === num \u0026\u0026 num % 1 !== 0;\n}\n\nfunction isInteger(num) {\n  return Number(num) === num \u0026\u0026 num % 1 === 0;\n}\n\nconsole.log(isFloat(3.14)); // Output: true\n\nconsole.log(isFloat(5)); // Output: false\n\nconsole.log(isInteger(5)); // Output: true\n\nconsole.log(isInteger(3.14)); // Output: false\n\n// Explanation: The isFloat function checks if the number is a float by comparing it with its integer value and checking if it has a non-zero decimal part. The isInteger function checks if the number is an integer by comparing it with its integer value and checking if it has a zero decimal part.\n```\n\nProgram to Pass a Function as Parameter\n\n```javascript\nfunction greet(name) {\n  return \"Hello, \" + name + \"!\";\n}\n\nfunction welcome(greetFunction, name) {\n  return greetFunction(name);\n}\n\nconsole.log(welcome(greet, \"Alice\")); // Output: Hello, Alice!\n\n// Explanation: The welcome function takes a function as a parameter and calls it with the provided name parameter.\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Get the Dimensions of an Image\n\n```javascript\nconst img = new Image();\n\nimg.src = \"image.jpg\";\n\nimg.onload = function() {\n  console.log(\"Image width: \" + this.width);\n  console.log(\"Image height: \" + this.height);\n};\n\n// Output: Image width: 800 Image height: 600\n```\n\nProgram to Remove All Whitespaces From a Text\n\n```javascript\nconst text = \"  Hello, World!  \";\n\nconst trimmedText = text.replace(/\\s/g, \"\");\n\nconsole.log(\"Original text: \" + text);\n\nconsole.log(\"Trimmed text: \" + trimmedText);\n\n// Output: Original text: Hello, World! Trimmed text: Hello,World!\n```\n\nProgram to Write to Console\n\n```javascript\nconsole.log(\"Hello, World!\");\n\n// Output: Hello, World!\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Convert Date to Number\n\n```javascript\nconst date = new Date();\n\nconst timestamp = date.getTime();\n\nconsole.log(\"Timestamp: \" + timestamp);\n\n// Output: Timestamp: 1635648000000\n```\n\nProgram to Get the Last Element of an Array\n\n```javascript\nconst fruits = [\"Apple\", \"Banana\", \"Orange\", \"Mango\"];\n\nconst lastFruit = fruits[fruits.length - 1];\n\nconsole.log(\"Last fruit: \" + lastFruit);\n// Output: Last fruit: Mango\n```\n\nProgram to Get the Current Time\n\n```javascript\nconst date = new Date();\n\nconst hours = date.getHours();\nconst minutes = date.getMinutes();\nconst seconds = date.getSeconds();\n\nconsole.log(\"Current time: \" + hours + \":\" + minutes + \":\" + seconds);\n// Output: Current time: 12:00:00\n```\n\n[Back to Top⤴️](#table-of-contents)\n\nProgram to Get the Current Day\n\n```javascript\nconst date = new Date();\n\nconst days = [\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"];\n\nconst day = days[date.getDay()];\n\nconsole.log(\"Today is: \" + day);\n// Output: Today is: Friday\n```\n\nProgram to Get the Current Month\n\n```javascript\nconst date = new Date();\n\nconst months = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"];\n\nconst month = months[date.getMonth()];\n\nconsole.log(\"Current month: \" + month);\n// Output: Current month: June\n```\n\nProgram to Get the Current Year\n\n```javascript\nconst date = new Date();\n\nconst year = date.getFullYear();\n\nconsole.log(\"Current year: \" + year);\n// Output: Current year: 2024\n```\n\nCount the character 'l' in the string \"Hello, World!\"\n\n```javascript\nconst str = \"Hello, World!\";\n\nlet count = 0;\n\nfor (let i = 0; i \u003c str.length; i++) {\n  if (str[i] === 'l') {\n    count++;\n  }\n}\n\nconsole.log(\"The number of occurrences of 'l' in the string is: \" + count);\n// Output: The number of occurrences of 'l' in the string is: 3\n```\n\nCount the number of words in the string \"Hello, World!\"\n\n```javascript\nconst str = \"Hello, World!\";\n\nconst words = str.split(\" \");\n\nconsole.log(\"The number of words in the string is: \" + words.length);\n// Output: The number of words in the string is: 2\n```\n\nFind the largest element in an array.\n\n```javascript\nconst numbers = [10, 5, 20, 15, 30];\n\nconst largest = Math.max(...numbers);\n\nconsole.log(\"Largest number: \" + largest);\n\n// Output: Largest number: 30\n```\n\nFind the smallest element in an array.\n\n```javascript\nconst numbers = [10, 5, 20, 15, 30];\n\nconst smallest = Math.min(...numbers);\n\nconsole.log(\"Smallest number: \" + smallest);\n\n// Output: Smallest number: 5\n```\n\nFind the largest element in an array without using any built-in functions/methods.\n\n```javascript\nconst numbers = [10, 5, 20, 15, 30];\n\nlet largest = numbers[0];\n\nfor (let i = 1; i \u003c numbers.length; i++) {\n  if (numbers[i] \u003e largest) {\n    largest = numbers[i];\n  }\n}\n\nconsole.log(\"Largest number: \" + largest);\n\n// Output: Largest number: 30\n```\n\nFind the smallest element in an array without using any built-in functions/methods.\n\n```javascript\nconst numbers = [10, 5, 20, 15, 30];\n\nlet smallest = numbers[0];\n\nfor (let i = 1; i \u003c numbers.length; i++) {\n  if (numbers[i] \u003c smallest) {\n    smallest = numbers[i];\n  }\n}\n\nconsole.log(\"Smallest number: \" + smallest);\n\n// Output: Smallest number: 5\n```\n\nReverse an array without using any built-in functions/methods.\n\n```javascript\nconst numbers = [1, 2, 3, 4, 5];\n\nfor (let i = 0; i \u003c (numbers.length - 1) / 2; i++) {\n  const temp = numbers[i];\n  numbers[i] = numbers[numbers.length - 1 - i];\n  numbers[numbers.length - 1 - i] = temp;\n}\n\nconsole.log(\"Reversed array: \" + numbers);\n\n// Output: Reversed array: 5,4,3,2,1\n```\n\nFind the missing number in an array of size n containing numbers from 1 to n+1 without using any built-in functions/methods.\n\n```javascript\nconst numbers = [1, 2, 3, 4, 6, 7, 8, 9, 10];\n\nconst n = numbers.length + 1;\n\nlet sum = (n * (n + 1)) / 2;\n\nfor (let i = 0; i \u003c numbers.length; i++) {\n  sum -= numbers[i];\n}\n\nconsole.log(\"The missing number is: \" + sum);\n\n// Output: The missing number is: 5\n```\n\nMove all zeroes to the end of the array without using any built-in functions/methods.\n\n```javascript\nconst numbers = [0, 2, 0, 4, 0, 6, 0, 8];\n\nlet count = 0;\n\nfor (let i = 0; i \u003c numbers.length; i++) {\n  if (numbers[i] !== 0) {\n    numbers[count] = numbers[i];\n    count++;\n  }\n}\n\nwhile (count \u003c numbers.length) {\n  numbers[count] = 0;\n  count++;\n}\n\nconsole.log(\"Array with zeroes at the end: \" + numbers);\n\n// Output: Array with zeroes at the end: 2,4,6,8,0,0,0,0\n```\n\nFind the \"Kth\" largest element in an array without using any built-in functions/methods.\n\n```javascript\nconst numbers = [10, 5, 20, 15, 30];\n\nconst k = 2;\n\nfor (let i = 0; i \u003c k; i++) {\n  let max = 0;\n  let maxIndex = 0;\n\n  for (let j = 0; j \u003c numbers.length; j++) {\n    if (numbers[j] \u003e max) {\n      max = numbers[j];\n      maxIndex = j;\n    }\n  }\n\n  numbers[maxIndex] = 0;\n}\n\nconsole.log(\"The \" + k + \"th largest element is: \" + max);\n\n// Output: The 2th largest element is: 20\n```\n\nFind the \"Kth\" smallest element in an array without using any built-in functions/methods.\n\n```javascript\nconst numbers = [10, 5, 20, 15, 30];\n\nconst k = 2;\n\nfor (let i = 0; i \u003c k; i++) {\n  let min = numbers[i];\n  let minIndex = i;\n\n  for (let j = i + 1; j \u003c numbers.length; j++) {\n    if (numbers[j] \u003c min) {\n      min = numbers[j];\n      minIndex = j;\n    }\n  }\n\n  // Swap the found minimum element with the element at index i\n  [numbers[i], numbers[minIndex]] = [numbers[minIndex], numbers[i]];\n}\n\nconsole.log(\"The \" + k + \"th smallest element is: \" + numbers[k - 1]);\n\n// Output: The 2th smallest element is: 10\n```\n\nFind the subarray with the given sum in a non-negative array without using any built-in functions/methods.\n\n```javascript\nconst numbers = [1, 4, 20, 3, 10, 5];\n\nconst targetSum = 33;\n\nlet start = 0;\n\nlet sum = numbers[0];\n\nfor (let i = 1; i \u003c= numbers.length; i++) {\n  while (sum \u003e targetSum \u0026\u0026 start \u003c i - 1) {\n    sum -= numbers[start];\n    start++;\n  }\n\n  if (sum === targetSum) {\n    console.log(\"Subarray with the given sum found between indexes \" + start + \" and \" + (i - 1));\n    break;\n  }\n\n  if (i \u003c numbers.length) {\n    sum += numbers[i];\n  }\n}\n\n// Output: Subarray with the given sum found between indexes 2 and 4\n```\n\nKadane’s Algorithm: Find the maximum sum subarray without using any built-in functions/methods.\n\n```javascript\nconst numbers = [-2, -3, 4, -1, -2, 1, 5, -3];\n\nlet maxSum = numbers[0];\n\nlet currentSum = numbers[0];\n\nfor (let i = 1; i \u003c numbers.length; i++) {\n  if (currentSum + numbers[i] \u003e numbers[i]) {\n    currentSum = currentSum + numbers[i];\n  } else {\n    currentSum = numbers[i];\n  }\n  \n  if (currentSum \u003e maxSum) {\n    maxSum = currentSum;\n  }\n}\n\nconsole.log(\"Maximum sum subarray: \" + maxSum);\n\n// Output: Maximum sum subarray: 7\n```\n\nTwo Sum Problem: Find pairs in an array that sum to a target value without using any built-in functions/methods.\n\n```javascript\nconst numbers = [2, 7, 11, 15];\n\nconst target = 9;\n\nconst pairs = [];\n\nfor (let i = 0; i \u003c numbers.length; i++) {\n  for (let j = i + 1; j \u003c numbers.length; j++) {\n    if (numbers[i] + numbers[j] === target) {\n      pairs[pairs.length] = [numbers[i], numbers[j]];\n    }\n  }\n}\n\nconsole.log(\"Pairs that sum to \" + target + \": \" + pairs);\n\n// Output: Pairs that sum to 9: 2,7\n```\n\nMerge two sorted arrays without using any built-in functions/methods.\n\n```javascript\nconst arr1 = [1, 3, 5, 7];\nconst arr2 = [2, 4, 6, 8];\n\nconst mergedArray = [];\n\nlet i = 0;\n\nlet j = 0;\n\nwhile (i \u003c arr1.length \u0026\u0026 j \u003c arr2.length) {\n  if (arr1[i] \u003c arr2[j]) {\n    mergedArray[mergedArray.length] = arr1[i];\n    i++;\n  } else {\n    mergedArray[mergedArray.length] = arr2[j];\n    j++;\n  }\n}\n\nwhile (i \u003c arr1.length) {\n  mergedArray[mergedArray.length] = arr1[i];\n  i++;\n}\n\nwhile (j \u003c arr2.length) {\n  mergedArray[mergedArray.length] = arr2[j];\n  j++;\n}\n\nconsole.log(\"Merged array: \" + mergedArray);\n\n// Output: Merged array: 1,2,3,4,5,6,7,8\n```\n\nFind the longest increasing subsequence in an array without using any built-in functions/methods.\n\n```javascript\nconst numbers = [10, 22, 9, 33, 21, 50, 41, 60, 80];\n\nconst lis = [];\nfor (let i = 0; i \u003c numbers.length; i++) {\n  lis[i] = 1;\n}\n\nfor (let i = 1; i \u003c numbers.length; i++) {\n  for (let j = 0; j \u003c i; j++) {\n    if (numbers[i] \u003e numbers[j] \u0026\u0026 lis[i] \u003c lis[j] + 1) {\n      lis[i] = lis[j] + 1;\n    }\n  }\n}\n\nlet maxLis = 0;\n\nfor (let i = 0; i \u003c lis.length; i++) {\n  if (lis[i] \u003e maxLis) {\n    maxLis = lis[i];\n  }\n}\n\nconsole.log(\"Length of the longest increasing subsequence: \" + maxLis);\n\n// Output: Length of the longest increasing subsequence: 6\n```\n\nTrapping Rain Water Problem without using any built-in functions/methods.\n\n```javascript\nconst heights = [0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1];\n\nlet totalWater = 0;\n\nfor (let i = 1; i \u003c heights.length - 1; i++) {\n  let leftMax = 0;\n  for (let j = 0; j \u003c i; j++) {\n    if (heights[j] \u003e leftMax) {\n      leftMax = heights[j];\n    }\n  }\n\n  let rightMax = 0;\n  for (let j = i + 1; j \u003c heights.length; j++) {\n    if (heights[j] \u003e rightMax) {\n      rightMax = heights[j];\n    }\n  }\n\n  const minMax = leftMax \u003c rightMax ? leftMax : rightMax;\n  totalWater += minMax \u003e heights[i] ? minMax - heights[i] : 0;\n\nconsole.log(\"Total trapped rainwater: \" + totalWater);\n\n// Output: Total trapped rainwater: 6\n}\n```\n\nReverse a string.\n\n```javascript\n\n````\n\nCheck if a string is a palindrome.\n\n```javascript\n\n````\n\nFind the first non-repeating character in a string.\n\n```javascript\n\n````\n\nFind the longest palindrome in a string.\n\n```javascript\n\n````\n\nCheck if two strings are anagrams.\n\n```javascript\n\n````\n\nImplement strstr() or indexOf().\n\n```javascript\n\n````\n\nLongest Common Prefix.\n\n```javascript\n\n````\n\nCount and say problem.\n\n```javascript\n\n````\n\nGroup anagrams together from a list of strings.\n\n```javascript\n\n````\n\nCheck if a string has balanced parentheses.\n\n```javascript\n\n````\n\nReverse a linked list (iterative and recursive).\n\n```javascript\n\n````\n\nDetect a cycle in a linked list (Floyd’s Cycle Detection).\n\n```javascript\n\n````\n\nFind the middle element of a linked list.\n\n```javascript\n\n````\n\nMerge two sorted linked lists.\n\n```javascript\n\n````\n\nRemove N-th node from the end of a linked list.\n\n```javascript\n\n````\n\nFind the intersection point of two linked lists.\n\n```javascript\n\n````\n\nDetect and remove a loop in a linked list.\n\n```javascript\n\n````\n\nFlatten a linked list.\n\n```javascript\n\n````\n\nRotate a linked list.\n\n```javascript\n\n````\n\nClone a linked list with random pointers.\n\n```javascript\n\n````\n\nImplement a stack using arrays or linked lists.\n\n```javascript\n\n````\n\nImplement a queue using stacks.\n\n```javascript\n\n````\n\nImplement a stack that supports getMin() in constant time.\n\n```javascript\n\n````\n\nNext Greater Element in a stack.\n\n```javascript\n\n````\n\nDesign a circular queue.\n\n```javascript\n\n````\n\nEvaluate postfix/prefix expressions.\n\n```javascript\n\n````\n\nImplement a LRU (Least Recently Used) Cache.\n\n```javascript\n\n````\n\nCheck for balanced parentheses using a stack.\n\n```javascript\n\n````\n\nSort a stack.\n\n```javascript\n\n````\n\nFind the largest rectangle in a histogram.\n\n```javascript\n\n````\n\nInorder/Preorder/Postorder traversal of a binary tree (recursive and iterative).\n\n```javascript\n\n````\n\nLevel order traversal of a binary tree.\n\n```javascript\n\n````\n\nFind the height of a binary tree.\n\n```javascript\n\n````\n\nCheck if two trees are identical.\n\n```javascript\n\n````\n\nFind the diameter of a binary tree.\n\n```javascript\n\n````\n\nCheck if a binary tree is a mirror of itself (symmetric).\n\n```javascript\n\n````\n\nFind the lowest common ancestor (LCA) of two nodes in a binary tree.\n\n```javascript\n\n````\n\nConvert a binary tree into its mirror tree.\n\n```javascript\n\n````\n\nPrint the boundary nodes of a binary tree.\n\n```javascript\n\n````\n\nFind the path from the root to a given node in a binary tree.\n\n```javascript\n\n````\n\nInsert a node in a binary search tree.\n\n```javascript\n\n````\n\nDelete a node from a binary search tree.\n\n```javascript\n\n````\n\nFind the inorder successor/predecessor of a node in a BST.\n\n```javascript\n\n````\n\nCheck if a binary tree is a binary search tree (BST).\n\n```javascript\n\n````\n\nFind the k-th smallest/largest element in a BST.\n\n```javascript\n\n````\n\nConvert a BST into a sorted doubly linked list.\n\n```javascript\n\n````\n\nMerge two binary search trees.\n\n```javascript\n\n````\n\nCheck if there’s a pair with a given sum in a BST.\n\n```javascript\n\n````\n\nConstruct a BST from a sorted array.\n\n```javascript\n\n````\n\nFind the range sum in a binary search tree.\n\n```javascript\n\n````\n\nImplement a min/max heap.\n\n```javascript\n\n````\n\nFind the k-th largest/smallest element in an array using a heap.\n\n```javascript\n\n````\n\nMerge k sorted arrays using a heap.\n\n```javascript\n\n````\n\nFind the median in a stream of integers.\n\n```javascript\n\n````\n\nCheck if a binary tree is a heap.\n\n```javascript\n\n````\n\nFind the top K frequent elements in a stream of data.\n\n```javascript\n\n````\n\nSort an array using heap sort.\n\n```javascript\n\n````\n\nRearrange characters in a string such that no two adjacent characters are the same using a heap.\n\n```javascript\n\n````\n\nDepth First Search (DFS) and Breadth First Search (BFS).\n\n```javascript\n\n````\n\nCheck if a graph is bipartite.\n\n```javascript\n\n````\n\nDetect a cycle in a directed/undirected graph.\n\n```javascript\n\n````\n\nFind the shortest path in an unweighted graph (BFS).\n\n```javascript\n\n````\n\nDijkstra's Algorithm for shortest path in a weighted graph.\n\n```javascript\n\n````\n\nTopological Sorting of a directed graph.\n\n```javascript\n\n````\n\nFind the strongly connected components in a graph (Kosaraju’s Algorithm).\n\n```javascript\n\n````\n\nPrim’s and Kruskal’s Algorithm for Minimum Spanning Tree (MST).\n\n```javascript\n\n````\n\nFlood Fill Algorithm.\n\n```javascript\n\n````\n\nFind if there’s a path between two nodes in a graph.\n\n```javascript\n\n````\n\n0/1 Knapsack problem.\n\n```javascript\n\n````\n\nLongest Common Subsequence.\n\n```javascript\n\n````\n\nLongest Increasing Subsequence.\n\n```javascript\n\n````\n\nCoin Change Problem.\n\n```javascript\n\n````\n\nRod Cutting Problem.\n\n```javascript\n\n````\n\nSubset Sum Problem.\n\n```javascript\n\n````\n\nEdit Distance Problem.\n\n```javascript\n\n````\n\nEgg Dropping Problem.\n\n```javascript\n\n````\n\nFibonacci number using dynamic programming.\n\n```javascript\n\n````\n\nWord Break Problem.\n\n```javascript\n\n````\n\nFind the majority element in an array (element that appears more than n/2 times).\n\n```javascript\n\n````\n\nFind the median of two sorted arrays.\n\n```javascript\n\n````\n\nCount inversions in an array.\n\n```javascript\n\n````\n\nBest time to buy and sell stock.\n\n```javascript\n\n````\n\nReservoir sampling.\n\n```javascript\n\n````\n\nFind the minimum number of platforms required for a railway station.\n\n```javascript\n\n````\n\nK-th largest element in a stream.\n\n```javascript\n\n````\n\nMedian of a stream of integers.\n\n```javascript\n\n````\n\nFind the longest consecutive sequence in an array.\n\n```javascript\n\n````\n\nSliding window maximum.\n\n```javascript\n\n````\n\n[Back to Top⤴️](#table-of-contents)\n\n## List of GitHub Repositories to learn JavaScript\n\n- [30 Days of JavaScript](https://github.com/Asabeneh/30-Days-Of-JavaScript)\n- [You Don't Know JavaScript](https://github.com/getify/You-Dont-Know-JS)\n- [Wtfjs](https://github.com/denysdovhan/wtfjs)\n- [JavaScript30](https://github.com/wesbos/JavaScript30)\n- [Clean Code JavaScript](https://github.com/ryanmcdermott/clean-code-javascript)\n- [JavaScript Questions](https://github.com/lydiahallie/javascript-questions)\n- [ES6 For Humans](https://github.com/metagrover/ES6-for-humans)\n- [Javascript Algorithms](https://github.com/trekhleb/javascript-algorithms)\n- [Js Stack From Scratch](https://github.com/verekia/js-stack-from-scratch)\n- [30 Seconds of Code](https://github.com/30-seconds/30-seconds-of-code)\n- [Airbnb Js Style Guide](https://github.com/airbnb/javascript)\n- [Js The Right Way](https://github.com/braziljs/js-the-right-way)\n- [33 Js Concepts](https://github.com/leonardomso/33-js-concepts)\n- [Awesome JavaScript](https://github.com/sorrycc/awesome-javascript)\n- [Modern Js CheatSheet](https://github.com/mbeaudru/modern-js-cheatsheet)\n- [Jstips](https://github.com/loverajoel/jstips)\n- [Awesome JavaScript Projects](https://github.com/Vishal-raj-1/Awesome-JavaScript-Projects)\n- [Project Guidelines](https://github.com/elsewhencode/project-guidelines)\n- [Nodebestpractices](https://github.com/goldbergyoni/nodebestpractices)\n- [JavaScript Testing Best Practices](https://github.com/goldbergyoni/javascript-testing-best-practices)\n- [JavaScript Interview Questions](https://github.com/sudheerj/javascript-interview-questions)\n- [Must Watch JavaScript](https://github.com/AllThingsSmitty/must-watch-javascript)\n\n## List of Websites to learn JavaScript\n\n- [W3School](https://www.w3schools.com/)\n- [MDN](https://developer.mozilla.org/en-US/)\n- [GeeksForGeeks](https://www.geeksforgeeks.org/)\n- [DevDocs](https://devdocs.io/)\n- [Programiz](programiz.com)\n- [Freecodecamp](https://www.freecodecamp.org/)\n- [Javatpoint](https://www.javatpoint.com/)\n- [Javascript.info](https://javascript.info/)\n- [Tutorialspoint](https://www.tutorialspoint.com/index.htm)\n- [Udemy](https://www.udemy.com/)\n- [YouTube](https://www.youtube.com)\n- [Stackoverflow](https://stackoverflow.com)\n\n## List of Books to learn JavaScript\n\n- [Eloquent JavaScript](https://eloquentjavascript.net/)\n- [You Don’t Know JS](https://www.amazon.in/You-Dont-Know-Set-Volumes/dp/9352136268)\n- [Effective JavaScript](https://www.amazon.in/Effective-JavaScript-Specific-Software-Development/dp/0321812182)\n- [JavaScript: The Good Parts](https://www.oreilly.com/library/view/javascript-the-good/9780596517748/)\n- [JavaScript: The Definitive Guide](https://www.oreilly.com/library/view/javascript-the-definitive/9781491952016/)\n- [A Smarter Way to Learn JavaScript](https://asmarterwaytolearn.com/js/index-of-exercises.html)\n- [Programming JavaScript Applications](https://www.oreilly.com/library/view/programming-javascript-applications/9781491950289/)\n\n## List of YouTube Channels to learn JavaScript\n\n- [Freecodecamp](https://www.youtube.com/@freecodecamp)\n- [Code With Harry](https://www.youtube.com/@CodeWithHarry)\n- [Programming With Mosh](https://www.youtube.com/@programmingwithmosh)\n- [Hitesh Choudhary](https://www.youtube.com/@HiteshChoudharydotcom)\n- [Clever Programmer](https://www.youtube.com/@CleverProgrammer)\n- [JavaScript Mastery](https://www.youtube.com/@javascriptmastery)\n- [Traversy Media](https://www.youtube.com/@TraversyMedia)\n- [Yahoo Baba](https://www.youtube.com/@YahooBaba)\n- [The New Boston](https://www.youtube.com/@thenewboston)\n- [LearnCode. academy](https://www.youtube.com/@learncodeacademy)\n- [Academind](https://www.youtube.com/@academind)\n- [LearnWebCode](https://www.youtube.com/@LearnWebCode)\n- [Wes Bos](https://www.youtube.com/@WesBos)\n- [WebDevMentors](https://www.youtube.com/@webdevmentors)\n- [Codevolution](https://www.youtube.com/@Codevolution)\n- [Codecademy](https://www.youtube.com/@codecademy)\n- [Daily Tuition](https://www.youtube.com/@DailyTuition)\n- [WebDevSimplified](https://www.youtube.com/WebDevSimplified)\n- [Harshit Vashisth](https://www.youtube.com/@Harshitvashisth)\n- [AniaKubow](https://www.youtube.com/@AniaKubow)\n\n## List of Udemy Courses to learn JavaScript\n\n- [The Complete JavaScript Course 2021: From Zero to Expert!](https://www.udemy.com/course/the-complete-javascript-course/)\n- [JavaScript - The Complete Guide 2021 (Beginner + Advanced)](https://www.udemy.com/course/javascript-the-complete-guide-2020-beginner-advanced/)\n- [Modern JavaScript From The Beginning](https://www.udemy.com/course/modern-javascript-from-the-beginning/)\n- [JavaScript Web Projects: 20 Projects to Build Your Portfolio](https://www.udemy.com/course/javascript-web-projects-to-build-your-portfolio-resume/)\n\n## List of Games to learn JavaScript by playing\n\n- [JSRobot](https://lab.reaal.me/jsrobot/)\n- [JSdares](https://jsdares.com/)\n- [CodeCombat](https://codecombat.com/)\n- [CodinGame](https://www.codingame.com/start)\n- [Crunchzilla](https://www.crunchzilla.com/)\n- [Screeps](https://screeps.com/)\n\n## List of Blogs Sites to learn JavaScript\n\n- [Freecodecamp](https://www.freecodecamp.org/news)\n- [Medium](https://medium.com/)\n- [Dev.to](https://dev.to/)\n- [Hashnode](https://hashnode.com/)\n- [Hacker Noon](https://hackernoon.com/)\n\n## List of JavaScript Online Editors/Compilers\n\n- [Programiz JavaScript Online Compiler](https://www.programiz.com/javascript/online-compiler/)\n- [W3School JavaScript Online Editor](https://www.w3schools.com/js/js_editor.asp)\n- [Playcode](https://playcode.io/javascript-online)\n- [JSFiddle](https://jsfiddle.net/)\n- [One Complier](https://onecompiler.com/javascript)\n- [Tutorialspoint Online JavaScript Editor](https://www.tutorialspoint.com/online_javascript_editor.php)\n- [myComplier](https://www.mycompiler.io/online-javascript-editor)\n- [JS.do](https://js.do/)\n- [Codingninjas Online JavaScript Compiler](https://www.codingninjas.com/codestudio/online-compiler/online-javascript-compiler)\n- [Codepen](https://codepen.io/)\n- [Replit](https://replit.com/~)\n\n## List of Twitter Users\n\n- [Csaba Kissi](https://twitter.com/csaba_kissi)\n- [Codermarch](https://twitter.com/codemarch)\n- [Swapna Kumar Panda](https://twitter.com/swapnakpanda)\n- [Pratham](https://twitter.com/Prathkum)\n\n## List of LinkedIn Users\n\n- [Adrian Bogdan](https://www.linkedin.com/in/adrian-%F0%9F%9F%A3-b-b52348181/)\n- [Jayesh Choudary](https://www.linkedin.com/in/jayesh-choudhary-72444518b/)\n- [Pradeep Pandey](https://www.linkedin.com/in/pradeep-pandey-5a545a163/)\n\n[Back to top⤴️](#table-of-contents)\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\n- [Asabeneh](https://github.com/Asabeneh/30-Days-Of-JavaScript) - For his 30 Days of JavaScript challenge.\n- [JavaScript.info](https://javascript.info/) - For their comprehensive JavaScript tutorials.\n- [W3Schools](https://www.w3schools.com/) - For their interactive JavaScript tutorials.\n- [MDN Web Docs](https://developer.mozilla.org/en-US/) - For their detailed JavaScript documentation.\n- [FreeCodeCamp](https://www.freecodecamp.org/) - For their JavaScript tutorials and projects.\n- [Programiz](https://www.programiz.com/) - For their simple and easy-to-understand JavaScript tutorials.\n- [GeeksforGeeks](https://www.geeksforgeeks.org/) - For their JavaScript articles and tutorials.\n- [DevDocs](https://devdocs.io/) - For their JavaScript documentation.\n- [Codecademy](https://www.codecademy.com/) - For their interactive JavaScript courses.\n- [Stack Overflow](https://stackoverflow.com/) - For their vast collection of JavaScript questions and answers.\n\n## Connect with me\n\n- [Twitter](https://twitter.com/manthan_ank)\n- [LinkedIn](https://www.linkedin.com/in/manthanank)\n- [Facebook](https://www.facebook.com/manthanank/)\n- [Instagram](https://www.instagram.com/manthan_ank/)\n- [YouTube](https://www.youtube.com/@manthanank)\n- [GitHub](https://github.com/manthanank)\n\n## Support\n\nIf you like this learning repository and find it useful, consider buying me a coffee or sponsoring me through the GitHub Sponsor. Your support will help me to continue and bring more exciting projects. Thank you!\n\n[![Buy Me A Coffee](/assets/bmc-button.svg)](https://www.buymeacoffee.com/manthanank)\n\n[![Sponsor Me](https://img.shields.io/badge/Sponsor-GitHub-green)]([https://](https://github.com/sponsors/manthanank))\n\n---\n\nShow your support by 🌟 the repository.\n","funding_links":["https://www.buymeacoffee.com/manthanank","https://github.com/sponsors/manthanank"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanthanank%2Flearn-javascript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmanthanank%2Flearn-javascript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanthanank%2Flearn-javascript/lists"}