JavaScript Operators
JavaScript Operators
In this tutorial you will learn about the JavaScript Operators, types of operators and how to use this in JavaScript with programming examples. Here given you many programming examples for your better revision about Operators. Now start to learn Operators.
What are Operators?
An Operators is a symbol that are used to perform particular operations, that takes one or more arguments and operates on them to product a result. They can be used to assign the values, combine values, compare values, perform arithmetic and more.
There are different types of Operators are used in JavaScript, that are given below;
- Assignment Operators
- Arithmetic Operators
- String Operators
- Comparison Operators
Now, you learn one by one all the given Operators in detail, with programming examples for your better understanding.
Assignment Operators
The Assignment Operator is an Operator that are used to assign the value to a variable, it uses the Equal = symbol. Look below some programming.
Examples of Assignment Operator;
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>JS Operator</title> </head> <body> <script> var a = 6; var b = 8; var sum = a+b; document.write(sum); </script> </body> </html> |
Above example we add the two number with using the help of + operator and assign the result.
The addition assignment operator adds the value of the right operand to the value of the variable. Given below the example.
Examples of Assignment Operator (+=);
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>JS Operator</title> </head> <body> <script> var a = 6; var b = 8; a += b; document.write("Sum Result = "+a); </script> </body> </html> |
Output;
Above you see the programming and output of assignment operator, where we saw how to assign the value.
Arithmetic Operator
The Arithmetic Operator are used to perform arithmetic operations like (addition, subtraction, multiplication, and division) between the values (operands).
Here are the symbols used for the Arithmetic Operator to obtained the result.
- Addition +
- Subtraction –
- Multiplication *
- Division /
Now, we see the programming examples of Arithmetic Operator, using all the symbols given.
Examples of Arithmetic Operator (Addition & Subtraction);
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>JS Operator</title> </head> <body> <script> var a = 6; var b = 8; var sum = a+b; document.write("Sum Result = " + sum); </script> <br> <script> var x = 20; var y = 7; var subtract = x-y; document.write("Subtraction Result = " + subtract) </script> </body> </html> |
Output;
Above you can see the programming example, where we add and subtract between two number with using “Subtract –” and “Addition +” Operators.
Examples of Arithmetic Operator (Multiplication & Division);
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>JS Operator</title> </head> <body> <script> var a = 4; var b = 5; var sum = a*b; document.write("Multiplication Result = " + sum); </script> <br> <script> var x = 15; var y = 3; var subtract = x/y; document.write("Division Result = " + subtract) </script> </body> </html> |
Output;
You can see above programming and output of Arithmetic operator (Multiplication and Division), where the operation is done with multiply and divide operator between two operands.
Comparison Operators
The Comparison Operator compare its operands and return a Boolean based on whether the comparison is True or False. Given below the example where we compare with Comparison Operator the equality of two number.
Example of Comparison Operator;
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>JS Operator</title> </head> <body> <script> var a = 4; var b = 5; var compare = a==b document.write("Compare Result = " + compare); </script> <br> <script> var x = 15; var y = 15; var compare = x==y; document.write("Compare Result = " + compare) </script> </body> </html> |
Output;
Above you can see the programming example and also output of program, where we compare two numbers using the Comparison Operator, and we saw the result is in True or False (Boolean).
String Operators
The String Operator are used to attach or add the two strings value, the addition operator + and the addition assignment += are the string operator. Given below some examples of String operators where we concatenate two or three string values.
Programming Examples of String Operator;
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>JS Operator</title> </head> <body> <script> var fname = "Shubham"; var lname = "Verma"; var fullname = fname + lname; document.write("Full Name is; "+ fullname); </script> <br> <script> var fname = "Ramesh"; var lname = "Verma"; fname += lname; document.write("Full Name; "+fname) </script> </body> </html> |
Output;
Above you can see programming example an output of String Operator, where use + and += operator to concatenate two string values.
Example of String Operator, here we concatenate three string value with the help of String operator.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>JS Operator</title> </head> <body> <script> var a = "StudyMuch"; var b = "is the best"; var c = " Educational Website."; var sentence = a+b+c; document.write("Sentence;" +sentence); </script> </body> </html> |
Output;
You can see above programming example with output, where we attach the three string values in a Sentence with the help of addition operator.
So, in this tutorial you learned all the JavaScript Operators with definition and programming examples of all the operators given in tutorial. I hope you read this tutorial (chapter) better and learn something new about the JavaScript Operators.
Read Also –
35 Comments
Phyliss Habig · September 23, 2022 at 8:45 am
I like this website because so much useful stuff on here : D.
marizon ilogert · October 6, 2022 at 11:49 am
I enjoy what you guys are up too. This type of clever work and exposure! Keep up the superb works guys I’ve included you guys to my blogroll.
marizon ilogert · October 10, 2022 at 5:44 am
Thanks , I have recently been looking for information approximately this topic for a while and yours is the greatest I have discovered till now. However, what in regards to the bottom line? Are you sure concerning the supply?
Cinderella Odham · January 16, 2023 at 9:12 am
I have recently started a site, the information you offer on this website has helped me tremendously. Thank you for all of your time & work.
how to be a payment service provider · December 12, 2023 at 11:12 am
I like what you guys are up too. Such intelligent work and reporting! Keep up the excellent works guys I have incorporated you guys to my blogroll. I think it will improve the value of my website 🙂
situs rajamas · January 18, 2024 at 3:13 pm
Excellent article. I am experiencing many of these issues as well..
Cruises · January 19, 2024 at 5:32 am
This is a very good tip especially to those new to the blogosphere. Simple but very accurate info… Thank you for sharing this one. A must read post.
Bryanwromb · January 23, 2024 at 9:51 am
Thanks for magnificent info. What trips can you recommend in 2024? Astro tourism, eco diving, home swapping, train stations are the new food destinations,sports tourism, coolcationing, gig tripping, private group travel?
Beauty Spa in Queens · February 11, 2024 at 3:04 am
Hi! This is my first visit to your blog! We are a collection of volunteers and starting a new initiative in a community in the same niche. Your blog provided us beneficial information to work on. You have done a wonderful job!
betting guest posts · February 24, 2024 at 1:31 pm
I enjoy reading a post that can make people think. Also, thanks for allowing for me to comment.
Piano cu · February 25, 2024 at 2:12 pm
I was extremely pleased to find this web site. I need to to thank you for your time just for this fantastic read!! I definitely appreciated every part of it and i also have you saved as a favorite to see new stuff on your web site.
film porno · April 9, 2024 at 1:14 pm
Wow that was strange. I just wrote an really long comment but after I clicked submit my comment didn’t show up. Grrrr… well I’m not writing all that over again. Anyway, just wanted to say superb blog!
bokep indo · April 9, 2024 at 2:27 pm
Right now it looks like WordPress is the preferred blogging platform available right now. (from what I’ve read) Is that what you are using on your blog?
beveiligingscamera · May 5, 2024 at 7:27 pm
There’s certainly a great deal to find out about this subject. I love all of the points you have made.
xparkles · May 5, 2024 at 9:30 pm
This article is a refreshing change! The author’s unique perspective and thoughtful analysis have made this a truly fascinating read. I’m grateful for the effort he has put into crafting such an educational and provocative piece. Thank you, author, for offering your expertise and stimulating meaningful discussions through your outstanding writing!
digital media firm · May 6, 2024 at 5:14 am
Excellent article. I will be dealing with many of these issues as well..
situs bokep · May 6, 2024 at 6:09 am
I really appreciate this post. I have been looking everywhere for this! Thank goodness I found it on Bing. You’ve made my day! Thanks again
écran MacBook cassé · May 6, 2024 at 8:32 am
I was very pleased to discover this website. I want to to thank you for your time just for this fantastic read!! I definitely really liked every part of it and I have you book marked to look at new things on your web site.
roof Inspection · May 6, 2024 at 8:50 am
Good post. I learn something new and challenging on blogs I stumbleupon every day. It’s always exciting to read content from other authors and practice something from their sites.
situs bokep · May 6, 2024 at 8:47 pm
It is best to take part in a contest for the most effective blogs on the web. I’ll recommend this website!
film porno · May 7, 2024 at 4:11 am
Hello there, I discovered your web site by way of Google whilst looking for a comparable topic, your site got here up, it appears to be like great. I’ve bookmarked it in my google bookmarks.
PSL88 · June 18, 2024 at 10:27 am
I must thank you for the efforts you’ve put in penning this website. I’m hoping to check out the same high-grade content from you in the future as well. In fact, your creative writing abilities has inspired me to get my own website now 😉
Thca Flower · July 1, 2024 at 3:28 am
This is very interesting, You are a very skilled blogger. I have joined your rss feed and look forward to seeking more of your magnificent post. Also, I’ve shared your site in my social networks!
Thca Flower · July 1, 2024 at 7:22 am
Have you ever thought about creating an ebook or guest authoring on other sites? I have a blog centered on the same information you discuss and would really like to have you share some stories/information. I know my viewers would value your work. If you’re even remotely interested, feel free to send me an e mail.
pure cbd oil · July 1, 2024 at 8:57 am
I do agree with all of the ideas you’ve presented in your post. They are very convincing and will definitely work. Still, the posts are too short for novices. Could you please extend them a little from next time? Thanks for the post.
카지노파트너 · September 17, 2024 at 11:24 am
Hi! I’ve been following your weblog for some time now and finally got the courage to go ahead and give you a shout out from Lubbock Tx! Just wanted to say keep up the great work!
ซีรี่ย์จีน123 · September 20, 2024 at 5:14 am
whoah this blog is excellent i love reading your posts. Keep up the good work! You know, a lot of people are looking around for this information, you can help them greatly.
ไม่มีขั่นต่ำ 1uาท ก็เล่นไ · September 26, 2024 at 2:16 am
I have read several good stuff here. Definitely worth bookmarking for revisiting. I wonder how much effort you put to create such a great informative site.
เปอร์เซ็นต์ สล็อตpg วันนี · September 26, 2024 at 9:52 am
This is really interesting, You’re a very skilled blogger. I have joined your rss feed and look forward to seeking more of your wonderful post. Also, I’ve shared your website in my social networks!
cbd massage · November 2, 2024 at 11:00 am
of course like your web-site however you need to check the spelling on several of your posts. A number of them are rife with spelling problems and I in finding it very troublesome to inform the reality nevertheless I?ll surely come again again.
bokep indo colmek · November 3, 2024 at 10:47 am
Do you have a spam problem on this blog; I also am a blogger, and I was curious about your situation; many of us have developed some nice procedures and we are looking to exchange methods with others, be sure to shoot me an e-mail if interested.
cbd oil for cats · November 3, 2024 at 1:53 pm
Hello, Neat post. There is an issue together with your website in internet explorer, might test this? IE nonetheless is the market chief and a huge section of people will pass over your great writing because of this problem.
bokep indo viral terbaru · November 4, 2024 at 9:57 am
What?s Happening i’m new to this, I stumbled upon this I have found It absolutely helpful and it has aided me out loads. I hope to contribute & help other users like its helped me. Great job.
bokep jilbab · November 4, 2024 at 12:50 pm
I?ve recently started a web site, the information you offer on this site has helped me greatly. Thank you for all of your time & work.
smortergiremal · November 4, 2024 at 4:36 pm
Nice read, I just passed this onto a friend who was doing some research on that. And he actually bought me lunch since I found it for him smile Thus let me rephrase that: Thank you for lunch!