Prepaid Recharge Plans | Recharge & Bill Payment Offer

Last Update: Fri, 04 Feb 2022 18:31:04

Online English Dictionary
Word meaning with PartsOfSpeech, Examples, Antonyms & Synonyms from various popular sources:
A Simple Knowledgebase

 • ADS

 • CSS

 • EXCEL

 • IMAGE-SERVER

 • SCRIPTS

 • SEO

 • WEB-PAGE-LANGUAGES

 • WEB-SERVER

 • WEBSITE-MONITORING-AND-BACKUP


WEB-PAGE-LANGUAGES | JAVASCRIPT | VARIABLES-AND-OPERATORS

Declare variables and Assign value to variable

In JavaScript, identifiers are used to name variables, keywords, functions and labels. In JavaScript, the first character must be a letter, or an underscore (_), or a dollar sign ($). Subsequent characters may be letters, digits, underscores, or dollar signs. All JavaScript identifiers are case sensitive. E.g. the variables "lastName" and "lastname" are two different variables:


var a, b, c;     // Declare 3 variables
a = 5;           // Assign the value 5 to a
b = 6;           // Assign the value 6 to b
c = a + b;       // Assign the sum of a and b to c
var person = "Hege";

5 is a number while "5" is a string. When we use + sign with numbers, it adds them and when we use with string, it concatenates (joins) them. If you put a number in quotes, the rest of the numbers will be treated as strings, and concatenated.


Example - 8

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Variables</h2>

<p>The result of adding "5" + 2 + 3:</p>

<p id="demo"></p>

<script>
var x = "5" + 2 + 3;
document.getElementById("demo").innerHTML = x;
</script>

</body>
</html>

Run the above code (8)

JavaScript Comments

Not all JavaScript statements are "executed". Code after double slashes // or between /* and */ is treated as a comment. Comments are ignored, and will not be executed.

// single line comment

/*
Multi line comment
*/

JavaScript Arithmetic Operators

Arithmetic operators are used to perform arithmetic on numbers:

+   Addition
-   Subtraction
*   Multiplication
**   Exponentiation
/   Division
%   Modulus (Division Remainder)
++   Increment
--   Decrement


JavaScript Assignment Operators:

x += y     x = x + y
x -= y     x = x - y
x *= y     x = x * y
x /= y     x = x / y
x %= y     x = x % y
x **= y     x = x ** y

JavaScript String Operators

The + operator can also be used to add (concatenate) strings.


Example - 9

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Operators</h2>

<p>The assignment operator += can concatenate strings.</p>

<p id="demo"></p>

<script>
var txt1;
txt1 = "What a very ";
txt1 += "nice day";
document.getElementById("demo").innerHTML = txt1;
</script>

</body>
</html>

Run the above code (9)

Example - 10

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Operators</h2>

<p>Adding a number and a string, returns a string.</p>

<p id="demo"></p>

<script>
var x = 5 + 5;
var y = "5" + 5;
var z = "Hello" + 5;
document.getElementById("demo").innerHTML =
x + "<br>" + y + "<br>" + z;
</script>

</body>
</html>

Run the above code (10)

JavaScript Comparison Operators

==   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
?   ternary operator

JavaScript Logical Operators

&&   logical and
||   logical or
!   logical not