Forbrukslån Test 2017 | Puhelinliittymä vertailu | Kredittkort | Strømpriser | Billigste Hyttealarm | Båtforsikring | Billig Mobilabonnement | Tilstandsrapport Bolig
JavaScript programming

Increment/decrements Operator to javascript

The JavaScript programming and dicriment increment operator is used, usually a gradual increase and decrease of the variable to the default values. There are two types of increment operator; Namely a ++ and ++ a similar and there are two kinds detriment operator; Such a– and –a similar. Pre-increment ++ a is called (Pre-increment), and a ++ operator is called post-increment (Post-increment) operator. Similarly –a is called Pre detriment (Pre-increments) operator is called the post-a– detriment (Post-increment) operator.

Pre-increment:

Suppose var a = 5; var b = ++ a; The pre-increment (Pre-increment) operator used var b = ++ a; The statement reveals that the value of a variable 1 to 5 will be added to the 5 + 1 = 6, then assign the value of the variable b, or will be received. Now, if a and b are variable, variable browser is displayed, then will be displayed both in the browser 6.

Post-increment:

Suppose var a = 5; var b = a ++; The post-increment (Post-increment) operator used var b = a ++; The statement reveals that the old values of a variable 5 var b = a ++; Statement to be used, the variable b as the first to be received or assign a variable to 5 and then the old value of 1 to 5 will be added to the 5 + 1 = 6. Now, if a and b variable is displayed in the browser, but the browser will display a variable b variable 5 to 6 will be displayed.

Pre-decrements:

Suppose var a = 5; var b = – $ a; The Pre dicriment (Pre-dicrement) operator used var b = – a; The statement reveals that the value of a variable that will be minus 1 to 5 will be 5-1 = 4, then assign the value of the variable b, or will be received. Now, if a and b are variable browser is displayed, then both will be displayed in the browser 4.

Post-dicrement:

Suppose var a = 5; var b = $ a–; The post dicriment (Post-dicriment) operator used var b = a–; The statement reveals that the old values of a variable 5 var b = a–; Statement to be used, the variable b as the first to be received or assign a variable to 5 and then subtract 1 to 5 will be the old standard will be 5-1 = 4. Now, if a and b variable is displayed in the browser, but the browser will display a variable b variable 4, 5 will be displayed.

Practice Project:

<html>
<head>
<title> wwwtrickbd.com.bd</title>
<style>
body{background: #FFC;
font-size:20px;}
h2{color:#FF0066;}
</style>

</head>
<body>
<script type = “text/javascript”>
document.write(“<h2>Pre Increment </h2>”);
var a = 5;
document.write(“<p> A = ”
+ a + “.</p>”);
var b=++a;
document.write(“<p> For Pre Increment B = ”
+ b + “.</p>”);
document.write(“<p>After Pre Increment A = ”
+ a + “.</p>”);
document.write(“<h2>Post Increment </h2>”);
var c = 5;
document.write(“<p> C = ”
+ c + “.</p>”);
var d=c++;
document.write(“<p> For Post Increment D = ”
+ d + “.</p>”);
document.write(“<p>After Post Increment C = ”
+ c + “.</p>”);
document.write(“<h2>Pre decrement </h2>”);
var p = 5;
document.write(“<p> P = ”
+ p + “.</p>”);
var q=–p;
document.write(“<p> For Pre decrement Q = ”
+ q + “.</p>”);
document.write(“<p>After Pre decrement P = ”
+ p + “.</p>”);
document.write(“<h2>Post decrement </h2>”);
var x = 5;
document.write(“<p> X = ”
+ x + “.</p>”);
var y=x–;
document.write(“<p> For Post decrement Y = ”
+ y + “.</p>”);
document.write(“<p>After Post decrement X = ”
+ x + “.</p>”);
</script>
</body>

</html>

Notepad: to open a file type from the menu at the top of layer code by clicking on the Save as File name: index.html, Save as type: All files, save and open the index.html file with the Mozilla Firefox look like the image shown below.

Pre Increment

A = 5.

For Pre Increment B = 6.

After Pre Increment A = 6.

Post Increment

C = 5.

For Post Increment D = 5.

After Post Increment C = 6.

Pre decrement

P = 5.

For Pre decrement Q = 4.

After Pre decrement P = 4.

Post decrement

X = 5.

For Post decrement Y = 5.

After Post dicrement X = 4.

 

 

Comments

comments

About the author

Toriqul Islam Tusher

বলার মত কিছু নাই!

Leave a Comment