0% found this document useful (0 votes)
4K views

Javascript Notes

Javascript Notes

Uploaded by

Justin Ab
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4K views

Javascript Notes

Javascript Notes

Uploaded by

Justin Ab
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

literal/value = what type of data we pass to the variable is known as literal.

It
is also known as value/data.

Variable = Variable is a container which is used to store the data. In javascript


we can declare vairbale in three ways by using where, let, const keywords.

Declaration means var a;


Initialization means a=10;

Examples fot Token :-

1) var a = 10; where var = keyword, a = identifier, 10 = literal/value

* Javascript is purely object-oriented programing language


* Javascript can be used for both client and server-side

NOTE :- by the end each and everything in javascript is considered as "object"

-:DATA-TYPE'S :-

Premitive datatype
number
string
boolean
undefined
null

Non premitive datatype


array
object
function

Premitive datatype:-
In premitive datatype we store single value

1) number = any mathematical number in javascript is considered as number datatype


example :- 1,-1,0,-1.0,1.0

2) string = anything which is enclosed between 'single-quotes', "double" and


`backtick`

backtick was introduced in ES6 version

Advantage of using backtick(``) :-

* we can use single and double quotes inside backtick.


* we can write more than one line by using backtick, it is also known as "template
string" / "interpolation".
* we can even evaluate an expression by using ${} .

example :- console.log(`my hobbies are:


1) sleeping
2) sleeping
3) sleeping `)
output :-
my hobbies are:
1) sleeping
2) sleeping
3) sleeping
example :- var a = 10;
var b = 20;
console.log(`addition of ${a} and ${b} is ${a+b}`)

output :-

addition of {a} and ${b} is 30

3) Boolean = true and false keywords are considered as boolean value.


true=1
false=0

4) undefined = when we declare a variable and but not initialized a value to it js


engine will give a special value called undefined.

example :- var a;
console.log(a)

output = undefined

5) null = Instead of creating an undefined variable we can store an empty object


with the help of null keyword

"typeof null" is and "obeject"

Type of operator = It is used to check what type of data is given.

NOTE :- We use camel case in JavaScript


example:- StudentRegNum, StudentId

OPERATORS :-

operators are special symbols used to perform some specific task between two
operands

1) Arithmetic Operator [+, -, %, /, **(introduced in ES7) before that we use


math.pow]
2) Assignment Operator [+=, -=, *=, /=, %=, =]
3) Comparisson Operator [==, ===, !=, >, <, >=, <=]

written type of comparison operator is boolean(true or false)

examples :-
9<4>3<2>1>0 = false
10<3>4<10>9 = flase
4<4>4<0>0 = false

You might also like