0% found this document useful (0 votes)
78 views

Javascript Note Class 12 1

Uploaded by

kandelganesh123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views

Javascript Note Class 12 1

Uploaded by

kandelganesh123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

JAVASCRIPT

JAVASCRIPT is a programming language. We use it to give instructions to the computer.

Input (code) COMPUTER Output

Setting up VS CODE, SUBLIME TEXT , NOTEPAD </>


It is a free & popular code editor by Microsoft.

Out 1st JS CODE:

Console.log is used to log (print) a message to the console

- console.log("hello word");
- alert(" hello word");
- document.write("hello word");

Variable in JS :
Variables are containers for data

VARIABLE Rules:

- Variable names are case sensitive; "a" & "A" is different.


- Only letters, digits, underscore(_) and $ is allowed. (not even space)
- Only a letter, underscore(_) or $ should be 1st character.
- Reserved words can't be variable names.

Let, const & var :


Var : variable can be re-declared & updated. A global scope variable.

Let : Variable can't be re-declared but can be updated. A block scope variable .

Const : variable can't be re-declared or updated. A block scope variable .

Data types in JS :
Number, String, Boolean, UnderFined, Null, Biglnt, Symbol :

Number:

Eg, let a=5;

String :

Eg. Let fullname='anil sir';

Boolean :

Eg. isfollow= true;


Type of isfollow

Ans: Boolean

Underfined : let x=null;

Bigint and symbol: eg.

Let x = bigint ("123");

Let y = symbol ( "hello !");

Comment in JAVASCRIPT :
Part of code which is not executed.

// this is a single line comment

/* this is a multi-line

Comment . */

Operators in JAVASCRIPT :
Used to perform some operation on data.

Arithmetic operators

+,-,*,/
- Modulus '% reminder'
- Exponentiation 'for power value ie. Ab , 23 eg. A**B'
- Increment '++ or a=a+1'
- Decrement '- - or a=a-1'

Assignment Operators : (for assign the value)

= += -= *= %= **=
=:
eg. a=5, b=6;

Let a=5;

Alert("a =" a); // a=5

+= :
eg. a += 5; // a= a + 5

Let a=5;

a += 5; // a= a + 5;

Alert("a =" a); // a = 10

-= :
Eg. a -= 5; // a= a – 5

Let a=5;

A -= 2; // a= a – 2;

Alert("a =" a); // a = 3

*= :

eg. a *= 5; // a= a * 5

let a=5;

a *= 5; // a= a * 5;

alert("a =" a); // a = 25;

%= :

eg. a %=5; // a= a % 5 (reminder)

let a=5;

a %= 5 ; // a= a % 5;

alert ("a =" a); // a= 1;


**= :

eg. a **=5; // a= a ** 5 (power)

let a=5;

a **= 5; // a= a**5;

alert(" a =" a); // a = 3125

/= :
Eg. a /= 5; // a= a / 5

Let a=5;

a /= 2;

alert(" a =" a); // a= 2.5

Operators In JS :
Comparison Operators to compare 2 values .

Equal to == equal to & type ===

Not equal to != not equal to & type !==

Equal to == :

Eg. let a = 5, b = 2;

Console.log(" 5 == 2 ", a == b); // false

Let a=5, b=5;

Console.log ("5 == 5 ", a == b); // true

let a = 5; // number

let b = " 5" ; // string

Console.log (" a == b ", a==b); // true


Not equal to != :

Eg. let a = 5 , b = 2;

Console.log (" 5 != 2", a !=b ); // true

Let a = 5, b = 5 ;

Console.log ( " 5 != 5 " , a != b ); // false

equal to & type === : (strict)

let a = 5; // number

let b = " 5" ; // string

Console.log (" a === b ", a===b); // false

not equal to & type !== :

let a = 5; // number

let b = " 5" ; // string

Console.log (" a !== b ", a!==b); // true

Logical Operators :
Logical AND &&

Logical OR ||

Logical NOT !

Logical AND && :

Cond 1 Cond 2 Result


T T T
T F F
F T F
F F F
//Logical Operators

let a = 6;

let b = 5;

let cond1 = a > b; // true

let cond2 = a === 6; // true

Console.log ("cond1 && cond2 = " ,cond1 && cond2); // true

let a = 6 ;

let b = 5;

let cond1 = a > b; // true

let cond2 = a === 5; // false

Console.log (" cond1 && cond2 = ", cond1 && cond2); // false

Logical OR || :

Cond 1 Cond 2 Result (&&) Result (||)


T T T T
T F F T
F T F T
F F F F

Eg.

//Logicat Operators

let a = 6;

let b = 5 ;

Console.log (" cond1 || cond2 = ", a < b || a === 6 ); // true

Logical NOT ! : ( true to false , false to true )

Eg. //Logicat Operators

let a = 6;

let b = 5 ;
Console.log (" !(6<5) = ", !(a < b)); // false but answer is TRUE

You might also like