What is JavaScript??

JavaScript is a lightweight object oriented programming language.
Which is used to sevral website for scripting webpage.
It is interpreted full-fledge programming language. That enable danamic intractivity on website when applied to html document.

Why js born??

To create intractive website like:-
(1) Client-side validation
(2) Server-side validation
(3) Popup
(4) Events and many more...

Where use JavaScript??

* Client-side
* Server-side
* Mobile development
* Software development
JavaScript is a weakly typed language (dynamically typed). JavaScript can be used for Client-side developments as well as Server-side developments. JavaScript is both an imperative and declarative type of language. JavaScript contains a standard library of objects, like Array, Date, and Math, and a core set of language elements like operators, control structures, and statements.

Version Name Release Year Features
ES1 ECMAScript 1 1997 Initial Release
ES2 ECMAScript 2 1998 Minor Editorial Changes
ES3 ECMAScript 3 1999 Add :
  • Regular Expression
  • Exception Handling
  • switch case and do-while
  • try/catch
ES4 ECMAScript 4 Abandoned due to conflicts ...
ES5 ECMAScript 5 2009 Added :-
  • JavaScript “strict mode”
  • JSON support
  • JS getters and setters
ES6 ECMAScript 2015 2015 Added :-
  • let and const
  • Class declaration
  • import and export
  • for..of loop
  • Arrow functions
ES7 ECMAScript 2016 2016 Added :-
  • Block scope for variable
  • async/await
  • Array.includes function
  • Exponentiation Operator
ES8 ECMAScript 2017 2017 Added :-
  • Object.values
  • Object.entries
  • Object.getOwnPropertiesDescriptors
ES9 ECMAScript 2018 2018 Added :-
  • spread operator
  • rest parameters
ES10 ECMAScript 2019 2019 Added :-
  • Array.flat()
  • Array.flatMap()
  • Array.sort is now stable
ES11 ECMAScript 2020 2020 Added :-
  • BigInt primitive type
  • nullish coalescing operator
ES12 ECMAScript 2021 2021 Added :-
  • String.replaceAll() Method
  • Promise.any() Method
ES13 ECMAScript 2022 2022 Added :-
  • Top-level await
  • Static block inside classes
ES.Next Dynamic name for upcoming versions

What is ECMA??

European Computer Manufacturer's Association
ECMA is a organization to create a standard for technologies. It is provide rule, details and guideline.
The ECMAScript specification is a standardized specification of a scripting language developed by Brendan Eich of Netscape; initially named Mocha, then LiveScript, and finally JavaScript.

How to Add JavaScript in HTML Document ??

(1). Inpage / Internal
(2). External

What is JavaScript Comments??

(1) Single line comment.
(2) Multiline comment.


What is JavaScript Statements??

The javascript program is a set of intruction / list of instructions also called statement.

1. Semicolons:

Semicolons separate ==> js statements.
Semicolon ==> end the statement .

2. Code Blocks:

Js statements can be grouped together ==> curly brackets.
Grouping ==> purpose ==>Statements Execute together.

5. Keywords:

Keywords ==> reserved words for Js. cannot be used as a variable name.

What is JavaScript Syntax??

JavaScript Syntax is used to define the set of rules.
Syntax :-
console.log("On console");
document.write("On browser ");
Variable declaration :-
let c, d, e;
Assign value to the variable :-
c = 5;
Computer value of variables :-
d = c;
e = c/d;


!!! JavaScript varriable !!!

A JavaScript variable is the simple name of the storage location where data is stored. There are two types of variables :-
Local variables: Declare a variable inside of a block or function.
Global variables: Declare a variable outside of functions.

• There are some basic rules to declare a variable in JavaScript:

* JavaScript is a dynamically typed language so the type of variables is decided at runtime. Four ways to define varriable??
a= "HTML"
var b = "CSS";
let c = "javascript";
const d = "JAVa";

Diffrence between let, var and const??

Property var let const
Scope Function scoped Block scoped Block scoped
Redeclaration Yes No No
Re-Assign Yes Yes No
Hoisting Hoisted at top No Hoisted No Hoisted
Origins Pre ES2015 ES2015(ES6) ES2015(ES6)
Support Supported in the old version of Browser Not supported in the old version of the Browser Not supported in the old version of the Browser

There are majorly two types of languages.

Statically typed language :- Where each variable and expression type is already known at compile time. Once a variable is declared to be of a certain data type, it cannot hold values of other data types.
Example: C, C++, Java.


Dynamically typed languages:-These languages can receive different data types over time. In this type of language, we don’t need to specify whether the value in the variable is an integer, string, or any other data type like float, double, etc. The JavaScript Engine automatically understands the data type. We can re-assign any variable with any other value having another data type as given below.
Example: Ruby, Python, JavaScript


What is Datatypes in JavaScript??

Datatype are two type :- (1). Primitive(predefined). (2). NonPrimitive(Reference)

(A). Primitive DataTypes :-
1. Number (Decimal (float), Integer)
2. String (sequence of characters )
3. Undefined (value is not assigned)
4. Boolean (true and false.)
5. Null (only one possible value that is null.)
6. BigInt (numbers greater than 253-1 )
7. Symbol (used to create objects==>always be unique created using Symbol constructo)
(B). Non-primitive DataTypes :-
- The data types that are derived from primitive data types
1. Object (Having properties and methods)
2. Array (we can store more than one element under a single name.)
How to write DataTypes in javascript??
1. var x = 10 ; // (Number)
2. let x = BigInt("123456789012345678901234567890");
3. var x = "I am string" ; // (String)
4. var x ; // (Undefined)
5. var x = null ; // (Null)
6. var x = true ; // (Boolean)
7. var x = {name : "jay",age : 23, email : j@gmail.com} ; // (Object)
8. var x =[ 1, 2, 3, 4, 5, "jay", "rupa", true ] ; // (Array)
9. var d = new Date("2022-03-25");
10. var s = Symbol();
Primitive Non-Primitive
Primitive Data types are predefined. Non-Primitive data types are created by the programmer
Primitive Data types will have certain values. Non-Primitive data types can be NULL.
Size depends on the type of data structure. Size is not fixed
Examples are numbers and strings. Examples are Array and Linked List.
It can start with a lowercase. It can start with uppercase.

JavaScript Output

JavaScript Output defines the ways to display the output of a given code.
-(1). innerHTML :- document.getElementById("id").innerHTML;
-(2). document.write(): Used ==> testing purpose.and Syntax ==> document.write()
-(3). window.alert(): Display content ==> alert box. Syntax ==> window.alert("Career-Inspire on documents");
-(4). console.log(): Used ==> debuggingAnd Syntax==> console.log("CareerInspire on conole")
-(5). window.prompt() :- Take input from user. Syntax ==> window.prompt("Enter input")
-(6). window.confirm() :- Confirmation by user. Syntax ==> window.confirm("Enter input")
-(7). console.error("Somethig else error"): Used ==> debuggingAnd Syntax==> show red color on console
-(8). console.warn("Somethig else error"): Used ==> debuggingAnd Syntax==> show green color on console
-(9). console.clear(): Used ==> debuggingAnd Syntax==> console clean
-(10). console.time("testing"): Used ==> debuggingAnd Syntax==> testing
-(11). console.timeEnd("testing"): Used ==> debuggingAnd Syntax==> testing(time :- 0.05ms )
-(12). window.print() :- Confirmation and cancel by user. Syntax ==> window.print()
what is if, if-else statement ??

What is JavaScript Operators??

JavaScript operators perform the operation between two or more operands.


javascript String??

JavaScript String Object is a sequence of characters. It contains zero or more characters within single or double quotes.
const name = "String Content";
const str = new String("career-inspire");

const str1 = new String("vijay dinanath chouhan");
const str2 = "vijay dinanath chouhan";
console.log(str1 == str2); output :- true
console.log(str1 === str2); output :- false


name.length
name.slice(start, end) (2),(2, 4) ,(-10),(-9,-6)
name.substring(start, end)
name.substr(start, length)
name.replace("a","@")
name.replaceAll("a","@")
name.toUpperCase()
name.toLowerCase()
name.concat(" ","string-2")
name.trim()
name.trimStart()
name.trimEnd()
name.charAt(positionIndex)
name.charCodeAt(positionIndex)
name.split(" ")


What is loop in javascript??

JavaScript Arrays

JavaScript Array is a single variable that is used to store elements of different data types. JavaScript arrays are zero-indexed.
Two ways to declare an array.
(1). Array literal :- let arrayName = [value1, value2, ...];
(2). Using new keyword :- let arr = new Array();

Array.length
Array.toString()
Array.pop()
Array.push("val-last")
Array.shift()
Array.unshift("val-first")
Array.join("-")
Array.delete() :- delete array[0];
Array.concat(array2)
Array.flat() :- [[1,2],[3,4],[5,6]] ==> [...]
Array.splice(2, 0, "val1", "val2")
Array.slice(0,1)

javascript object??

Objects, in JavaScript, are the most important data type and form the building blocks for modern JavaScript.

1. Object Literal
2. Object Constructor

1. let object_name = { key_name : "value", ... }

2. const object1 = new Object();

let school = {
name : "Vivekanada",
location : "Delhi",
established : 1971,
displayinfo : function() {
console.log(`${school.name} was established
in ${school.established} at ${school.location}`);
}
}

What is math() method??

The Javascript Math object is used to perform mathematical operations on numbers.

Methods
Math.abs()
Math.cbrt()
Math.ceil()
Math.exp()
Math.floor()
Math.log()
Math.log10()
Math.log1p()
Math.log2()
Math.max()
Math.min()
Math.pow()
Math.random()
Math.round()
Math.sqrt()

Math.abs(-4.7): 4.7

Math.ceil(4.4): 5

Math.floor(4.7): 4

Math.sin(90 * Math.PI / 180): 1

Math.min(0, 150, 30, 20, -8, -200): -200

Math.random(): 0.9578893866660307

Math.SQRT2: 1.4142135623730951
Math.SQRT1_2: 0.7071067811865476
Math.LN2: 0.6931471805599453
Math.E: 2.718281828459045
Math.PI: 3.141592653589793


What is javascript functions??

Function :- One of the fundamental building blocks in JavaScript.
Function has a set of statements that performs a task.
Js function are used to perform the operation we can call the function many time.
Syntax :-
function functionName(parameters){
...peace of code...
}

* Function hoisting???
square(5) // 25
function square(n) { return n * n; }

Function declaration

function person() { }
let person = person()
console.log(person) // Undefined

function person1(name) {
return name;
}
console.log(person1) // Aayush
let person1 = person1("Aayush")

Function Constructor:-

let person = new Person();

Creating the Constructor function
function Person(name, age) {
this.name = name;
this.age = age;
}

// Calling the function
let person = new Person("Vikah", 22);

console.log(person.name);
console.log(person.age);

Anonymous fuction??

var myfun = function () {
console.log("I am Anonymous function!");
};
myfun();

setTimeout(function () {
console.log("I am Anonymous function call after 2 second!");
}, 2000);

var myFun = () =>
{
console.log("I am Anonymous Arrow function!");
}
myFun();

Return type fuction??

IIFC type fuction?? (Immediately Invoked Function Expressions)

(function() {
console.log("Welcome to IIFE!");
})();