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

Java Script IT Notes

The document provides comprehensive study material on JavaScript, covering its features, applications, data types, operators, and control structures such as loops and selection statements. It includes examples and explanations of variable declaration, types of scripting, and various operators. Additionally, it offers resources for further study through Telegram channels and bots for accessing notes and materials related to 11th and 12th-grade science topics.

Uploaded by

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

Java Script IT Notes

The document provides comprehensive study material on JavaScript, covering its features, applications, data types, operators, and control structures such as loops and selection statements. It includes examples and explanations of variable declaration, types of scripting, and various operators. Additionally, it offers resources for further study through Telegram channels and bots for accessing notes and materials related to 11th and 12th-grade science topics.

Uploaded by

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

Click on any image to get study material & all notes

Don't have Telegram yet? Try it now! Click Here To Join Telegram Channels

JOIN TELEGRAM ➭ @NEET_JEE_CET_QUIZ

JOIN TELEGRAM ➭@MHT_CET_EXAM_NOTES

12Th Science Notes Maharashtra Board


16 769 subscribers
27
05 HERE YOU GET ALL 11TH & 12TH STUDY MATERIAL

➥ NEET_JEE ➲ @NEET_JEE_CET_QUIZ

➥ MHT-CET ➲ @MHT_CET_CHANNEL

➥ USE BOT FOR ALL NOTES 01F


4DD

➥ ★ @SCIENCECENTRALBOT ★
➥ ★ @NEET_JEE_CET_BOT

⚠For more info.. https://t.me/notesforyou12th/1227


View in Telegram
Preview channel
If you have Telegram, you can view and join
12Th Science Notes Maharashtra Board right away.

Click Here To Join Telegram Channels

JOIN TELEGRAM ➭ @NEET_JEE_CET_QUIZ


JAVASCRIPT
JavaScript is an object oriented scripting language used in web pages.
It is an interpreted language.
It was developed by Brendan Eich at Netscape Communications in 1996.
JavaScript was first supported by Netscape Navigator Browser.
Q. 1. Explain features of JavaScript
Ans. Page No. 200
Q. 2. Give the applications of JavaScript.
Ans. Page No. 200 and 201
Q.3. Explain the two types of scripting.
Ans. Client Side Scripting - The scripts that are written to run on the web-site
visitor’s computer and browser are known as client side scripts. They are mainly
used for adding special effects, validating input data, change web page data, etc..
E.g. JavaScript, VBScript, Jscript, JQuery, Angular JS, etc..
Server Side Scripting - The scripts are executed on the Server and the output
generated is sent in HTML format to client . E.g. ASP, JSP, PHP

Variables in JavaScript
Variables are location in computer’s memory where values can be stored.
Variables are denoted with a symbol known as variable name. In JavaScript var
keyword is used to declare a variable.
E.g. var a;
a=40;
Q.4. What are the rules for naming a variable in JavaScript?
Rules for naming variables
 Variable name must always begin with letter. It can include digits
 It cannot contain any blank space or special symbol except underscore.
 The length variable is limited upto 255 characters.
 It cannot be reserved or standard keyword.
 Multiple type of declaration is not allowed.
 Variables name are case sensitive.
E.g. var first_name, b1234;
JavaScript support explicit as well as implicit declaration of variables.
Explicit declaration of variable
E.g. var a;
a = 25;

Implicit variable
a = 25;

Q.5. Explain the data types in JavaScript.


Data types of Variables
Each variable used in JavaScript belong to a specific data type.
The following are Primitive data types in JavaScript :
1) Number - contains whole number or decimal number
2) String - contains series of characters in quotation marks
3) Boolean - contains TRUE or FALSE values
4) Undefined - a variable without value is undefined
The data type of the variable can be displayed using typeof operator.

Q.6. Explain the different operators in JavaScript.


Operators
Unary Operators - they operate on single variable
++ - increases the value by 1
-- - decreases the value by 1
E.g. var a;
a = 25;
a++;
--a;
++a - Pre-increment operator
a++ - Post increment operator
--a - Pre-decrement operator
a-- - Post decrement operator

E.g.
a=5; b=4;
z = ++a + b++; z = ++a + ++b;
z = 6 + 4 z= 6 + 5
z = 10 z = 11

Binary Operators
These operators operate on two variables
+ - Addition
- - Subtraction
* - Multiplication
/ - Division
% - Modulus - returns remainder of division
= - Assignment operator – assigns value of expression on the right hand
to the variable on left hand

Composite assignment operator


+= Composite Addition operator
-=
*=
/=
%=

E.g. a+=2; means a=a+2;


<script>
var a, b, z;
a=5;
b=4;
document.write(" Value of a is " + a);
document.write("<br> Value of b is " + b);
a+=3; // means a = a + 3
b*=2; // means b = b * 2
z = a%b; // means a/b take remainder as answer
document.write("<br>Value of a is " + a);
document.write("<br>Value of b is " + b);
document.write("<br>Value of z is " + z);
</script>

Comparison Operator
Operator Description

== equal to

=== equal value and equal type

!= not equal

!== not equal value or not equal type

> greater than


< less than
>= greater than or equal to
<= less than or equal to
Logical Operators
Operator Description Example
&& and (x < 10 && y > 1) is true
|| or (x == 5 || y == 5) is false
! not !(x == y) is true
Conditional (Ternary) Operator
JavaScript also contains a conditional operator that assigns a value to a variable
based on some condition.
Syntax
variablename = (condition) ? value1:value2

Example
var a=20, b=30, max;
max = (a> b) ? a : b;

Comments in JavaScript
They are non-executable statements in JS program. Comments are
of two types :
Single line comment --- using //
Multi line comment ---- using /* */

Q. Write JS program to input two numbers and display sum and product.
Q. Write JS program to input a number and find whether it is even no.
Selection Statements (Decision making statements)

1. if (condition)
It evaluates the condition expression. If it is TRUE, It executes the block of
code under it. If FALSE, it will not execute.

E.g. if(age>18)
{ document.write(“You are eligible for voting”);

2. if(condition) else
It evaluates the condition expression. If it is TRUE, it executes the block of
code under it. If FALSE, it will execute the block of code under else statement.
E.g. if(age>18)
{ document.write(“You are eligible for voting”);

}
else
{ document.write(“You are not eligible for voting”);

Q. Write JS program to input age display whether eligible for voting.

3. if(condition) else if(condition) …. ladder


It is used to check value with multiple conditions. It is used to test a
sequence of parallel alternatives.

Syntax:
if(condition1)
{
Block1
}

else if(condition2)
{
Block2
}
else if(condition3)
{
Block3
}

else
{
Block4

Q. Write JS Program to input percentage and display grade.

4. switch … case
It is used to check variable or expression value with series of values and
execute the block under case statement.

Syntax:

switch (expression)
{
case value1 :

block1

case value2 :
block2

case value3 :

block3

default :

block4
}

Q. Write JS program to input day number of the week and display the day
in words. (E.g. Day number is 2 Output - Monday)

Q. Write JS Program to input rollno, name, marks in any three subjects.


Find GTotal, Percentage and Grade.

Looping Statements
They are used to execute a block of code certain number of times or until given
condition is true.
To create loop in JavaScript there are:

while() loop
do while() loop
for() loop

1. while loop
It executes a block of code until the condition given in it is TRUE.

Syntax:
while(condition)
{
code

Q. Write JS program to print Good Morning 5 times.


E.g.
C
<script>
6

var c=1;

while(c<=5)
{
document.write(“<br>Good Morning”);
c=c + 1;
}

document.write(“<br> Loop completed”);


</script>

Q. Write JS program to display numbers from 1 to 10.


<script>

var n=1;

document.write(“<h2>Display numbers from 1 to 10</h2>”);

while(n<=10)
{
document.write(“<br>” + n);
n=n+1;
}
</script>
LOOPS

To execute a block of code number of times until condition is true.

E.g. To display numbers from 1 to 10


<script>
var c;
c=1;

while(c<=10)
{

document.write("<br>" + c);
c=c+1;
}
</script>

Q. Display even numbers from 1 to 50


<script>
var c;
c=1;

while(c<=50)
{
if(c%2 == 0)
{ document.write("<br>" + c); }

c=c+1;
}
</script>

Q. Display numbers from 1 to 100 which are multiples of 4 and 5


<script>
var c;
c=1;

while(c<=100)
{
if(c%4 == 0 && c%5==0)
{ document.write("<br>" + c); }

c=c+1;
}
</script>

2. do while () loop
In do while loop, the condition is checked at the end of the loop. So the loop
will run atleast once even if the condition is false.
E.g. <script>
var c=1;

while(c<0)
{
document.write("<br>" + c);
c = c + 1;
}
</script>

3. for( ) loop
for loop provides initialization, condition and update of counter variable in
the for header.

E.g. Display numbers from 1 to 10


<script>

var c;
for( c=1; c<=10; c++)
{

document.write("<br>" + c);
}
</script>

Q. Write JS program to print numbers from 1 to 100 which are divisible by


3, 5 and 9 using for loop.
<script>
var c;
for( c=1; c<=100; c++)
{
if( )
{ document.write("<br>" + c); }

}
</script>

Q. Write JS program to print multiplication table of a number entered,


using for loop.
<script>

var c, num;

num = parseInt(prompt("Enter a number"));

document.write(" <h2> Multiplication Table</h2>");


for(c=1; c<=10;c++)
{

document.write("<br>" + num + " x " + c + " = " + num*c);

}
</script>
Q.Ans.
 What are the features of JavaScript?
 What are the applications of JavaScript?
 List the Unary, Binary, comparison and logical operators in
JavaScript.
 Explain the two types of scripting.
 List the different types of Assignment operators.
 Explain the different literals in JavaScript.
 Write the rules for naming variables in JavaScript.
 Explain the if..else selection statement of JavaScript.
 What is the use of loops? Give the structure of while loop.
 Explain the data types in JavaScript
 Explain the switch..case selection statement of JavaScript.
Click on any image to get study material & all notes
Don't have Telegram yet? Try it now! Click Here To Join Telegram Channels

JOIN TELEGRAM ➭ @NEET_JEE_CET_QUIZ

JOIN TELEGRAM ➭@MHT_CET_EXAM_NOTES

12Th Science Notes Maharashtra Board


16 769 subscribers
27
05 HERE YOU GET ALL 11TH & 12TH STUDY MATERIAL

➥ NEET_JEE ➲ @NEET_JEE_CET_QUIZ

➥ MHT-CET ➲ @MHT_CET_CHANNEL

➥ USE BOT FOR ALL NOTES 01F


4DD

➥ ★ @SCIENCECENTRALBOT ★
➥ ★ @NEET_JEE_CET_BOT

⚠For more info.. https://t.me/notesforyou12th/1227


View in Telegram
Preview channel
If you have Telegram, you can view and join
12Th Science Notes Maharashtra Board right away.

Click Here To Join Telegram Channels

JOIN TELEGRAM ➭ @NEET_JEE_CET_QUIZ

You might also like