Introduction
Thursday, 2 February 2023 9:10 am
Java script is front end language . used for changing changes in webpage-frontend developed by Brenban Eich in [Link] is the oldest language.
Backend-changes in account etc…for changing webpage dynamic.
Console window is in inspect page.
Java script is a interprator , runs line by line .even compiler is there
We have to use [Link]("'); to print in console statement
;--not mandatory
Syntax:
[Link]("hello world");
To get output(to run plain java script):
node [Link]
Comment:
Single line:\\
Multiline:\*
No need to specify type in java script we should saw as variable or it will take as string
3 types to declare variable Var,let,const;
Syntax:
Var a=12;
a="hai";(it will change the type for variable that is one advantage)
Int a;(saying to create 4 bytes of memory)
In c++ we can't redeclare variable but we can redeclare in java script;
No memory wastage in c++;
If we use var there is memory wastage.
Syntax:
Let a;
a=10;
(we can't [Link] is there to avoid memory wastage)
Syntax:
Const pi=3.14;
(will not change the value)
Datatypes:
1. String(string and char)
2. Number(int , float)
3. Boolean
4. Undefined(var a; var a is not initialised)
5. Null(will be used in object)
6. Object
Syntax:
Var num1;
[Link](typeof(num1));
o/p:undefined
String and char is same .we can give in single or double quotation.
Syntax:
Var arr=[1,2,3,4];
Array is saves in continuous memory location.
Syntax: (jason format)
Java Page 1
Syntax: (jason format)
We can give Space in variavle name but we sholud use[] to get that variable.
a===b(checks the datatype also)
Different types of javascript operators:
Arithmetic operators[+,-,+,**,/,%,++,--]
Assignment operators[=,+=,-=,*=,/=,%=,**=]
Comparision operators[==,!=,===,!==,<,>,<=,>=,?]
Logical Operators[&&,||,!]
Type Operators[typeof]
Java Page 2
ParseInt(camel caseing .default )
To convert string into integer
Syntax:
ParseInt(a)
Function:
Var Add(a,b)
{
[Link](a+b)
}
Add(a+b);
Arrow function(=>):
There if no function keyword or function name.
Ex:
Var add=(a,b)=>[Link](a+b);(add -var name)
Add(2,3);
(`)-->backtics(used if both single slash and double class is present.
Var str1="Hello world";
[Link]([Link]);(. Is used for [Link] class)
Var str1="welcome hello world";
[Link]([Link](8,13));
[Link]([Link](0,5));
Java Page 3