Domyhomework123.com - programming homework help. Get your programming homework done with expert homework helper. Trust Writemypaper123.com with your paper and you will never regret it.

## JavaScript Tutorial : Introduction to operators in JavaScript - Javascript Arithmetic Operators

Introduction To Operators in JavaScript
1→ Arithmetic Operators
2→ Comparison Operators
3→ Logical Operators
4→ Assignment Operators
5→ Condition Operators

Arithmetic Operators :

Operators   Description         Example
+                   Addition             var c = a + b;
-                    Subtraction        var c = a - b;
*                   Multiplication    var c = a * b;
/                    Division             var c = a / b;
%                  Modulus             var c = a % b;
++                 Increment           var c = ++a;
–                    Decrement         var c = -- a;

Examples on Arithmetic Operator :

```<html>
<body>
<script >
var b = 10,c = 15;
var a = b + c;
document.write(a);
</script>
</body>
</html>
```
Output : 25

Subtraction Example:-
```<html>
<body>
<script >
var b = 10,c = 5;
var a = b - c;
document.write(a);
</script>
</body>
</html>
```
Output : 5

Multiplication Example:-
```<html>
<body>
<script >
var b = 2,c = 3;
var a = b * c;
document.write(a);
</script>
</body>
</html>
```
Output : 6

Division Example:-
```<html>
<body>
<script >
var b = 10,c = 5;
var a = b / c;
document.write(a);
</script>
</body>
</html>
```
Output : 2

Modulus Example:-
```<html>
<body>
<script >
var b = 10,c = 5;
var a = b % c;
document.write(a);
</script>
</body>
</html>
```
Output : 0

Increment Example:-
```<html>
<body>
<script >
var b = 10,c = 5; var a = ++b;//pre-increment b++;//post-increment
var e =b;
document.write(a);
document.write('<br>'); //using HTML code
document.write(e);
</script>
</body>
</html>
```
Output : 11
12

Decrement Example:-
```<html>
<body>
<script >
var b = 10,;
var a = --b;
document.write(a);
</script>
</body>
</html>
```
Output : 9

JavaScript Introduction Part 1 : Checkout : Part 1

JavaScript Introduction Part 2 : Checkout : Part 2

JavaScript Introduction Part 3 : Checkout : Part 3
Konakalla Premsai
I love to make things simple :)

## JavaScript Tutorial : JavaScript in External File with examples - JavaScript Part 3

As we begin to work extensively in JavaScript,we will be likely to find that there are cases that where we are using identical JavaScript code on multiple pages. The Script tag allow us to store the JavaScript in a external file and the include to HTML files.

Example 1 :
```<html>
<script src="1.js" type="text/javascript"></script>
<body>
</body>
</html>
```
• Save this code as abc.html
• External JavaScript file   document.write("this is external js");
• save this code with the extension of .js like 1.js

Output :
this is external js

Usage of Variables in JavaScript :-
The keyword we use here is var.

Syntax : var nameofthevariable;

Example
```<html>
<body>
<script>
var a='example of variable';
var b='10';//
var c=15; //declaration of an integer.

document.write(a);
document.write(b);
document.write(c);
</script>
</body>
</html>
```
Output :
example of variable 1015

Now the data we put inside the single quotes are treated as string data. To declare an integer we must avoid using single quotes. That will be clearly explained in the following example.

Example :
```<html>
<body>
<script >
var b='10';
var c=15;
var d=c+b;

document.write(d);
</script>
</body>
</html>
```
Output : 1015

Example :
```<html>
<body>
<script>
var b = 10;
var c = 15;
var d = c+b;

document.write(d);
</script>
</body>
</html>
```
Output : 25

Explanation:- As we observed in the first example the variable b’s data was given inside the singe  quotes so is was stored as an string type. Now in the second example we declared all the variable as an integer so there Ari thematic operation was done.

Note: var a=10;var b=20;var c=’a+b’;

document.write(c);//output=a+b

because we have given the data inside an singlequotes.

Example :
```<html>
<body>
<script >
var b=10, c=15,d=c+b;
document.write(d);
</script>
</body>
</html>
```
Output : 25
Note:- there was no need to use var to create multiple variables you can also use the above approach.

JavaScript Introduction Part 1 : Checkout : Part 1

JavaScript Introduction Part 2 : Checkout : Part 2
Konakalla Premsai
I love to make things simple :)

## JavaScript Tutorial : Flexibility of using JavaScript anywhere in a HTML document. - JavaScript Part 2

Flexibility of using JavaScript anywhere in a HTML document.
2→ script in body section.
3→ script in both head and body sections.

JavaScript Introduction Part 1 : Checkout

Example 1 :
```<html>
<script>
</script>
<body>
</body>
</html>
```
Output :

Example 2 :
``` <html>
<body>
<script>
document.write("this is inside body");
</script>
</body>
</html>
```
Output :
this is inside body

Example 3 :
```<html>
<script>
</script>
<body>
<script>
document.write("this is inside body");
</script>
</body>
</html>
```
Output :
this is inside body

JavaScript Introduction Part 1 : Checkout
Konakalla Premsai
I love to make things simple :)

## JavaScript Tutorial : Introduction, Types of JavaScript, Syntax, Comments in javascript - JavaScript Part 1

Why javascript?
JavaScript is a lightweight,high-level,dynamic and interpreted programming language. Alongside HTML and CSS, JavaScript is one of the core technologies Web Development. JavaScript is used to make webpages interactive.

Who can learn JavaScript?
One should have prior knowledge of HTML coding and some exposure to object-oriented programming concepts .

Types of JavaScript
Same as CSS JavaScript also of three types
1→External.
2→ Internal.
3→ Inline.

Note:- JavaScript accepts both double and single quotes.

Syntax:
Javascript can be implemented using javascript statements
that are placed within the
```<script> .. </script>
```

Example:
```<html>
<body>
<script>
document.write("Welcome to JavaScript !");
</script>
</body>
</html>
```
Output:
Welcome to JavaScript !

Usage of Semicolons:
In JavaScript semicolons are optional. Unlike C,C++,Java languages JavaScript allows you to omit this semicolon if each of your statements are placed on a separate line.

Example 1:
```<html>
<body>
<script>
var a = 10
var 2 = 20
document.write(a)
document.write(b)
</script>
</body>
</html>
```
Output :
1020

Example 2:
```<html>
<body>
<script >
var a = 10;
var 2 = 20;
document.write(a);
document.write(b);
</script>
</body>
</html>
```
Output:
1020

The basic difference between example 1&2 was after each statement in the example 1 we didnt used semicolon,but in example 2 we used semicolon,basically the output was same in both the scenarios.

Note:- But it is not a good practice to ignore semicolons.

Case Sensitivity:
JavaScript is a case-sensitive language. This means that language variables,keywords etc must always be typed consistent capitalization of letters.
1) Any text between a // and the end of the line will be treated as a comment and it will be ignored by JavaScript.
2) Any text between /* and */ will also be treated as a comment and that will be ignored by JavaScript.
3) Any text between <!-- and //-- > will also be treated as a comment and that will be ignored by JavaScript.

Example:
```<html>
<body>
<script>
<!-- // This is a comment. used for single line comment same as c programming.
/* * This is a multi line comment in JavaScript * It is also similar to comments in C Programming */ //-- >
</script>
</body>
</html>
```

JavaScript Introduction Part 2 : Checkout