
Join the Conversation!
Subscribing gives you access to the comments so you can share your ideas, ask questions, and connect with others.
In this lesson, you'll learn about in JavaScript and how they are used to assign and manipulate values in variables.
An assignment operator assigns a value to its left operand based on the value of its right operand.
Would you believe me if I told you that you not only know what an assignment operator is, but that you've been using it this whole time? The simplest form of an assignment operator is the equal sign used for assigning values to variables:
const number = 5;
This right here is an assignment operator.
We can also combine the assignment operator with one of the arithmetic operators to perform an operation and assignment in one step:
let number = 5;
number += 5; // the same as number = number + 5;
number -= 5; // the same as number = number - 5;
number *= 5; // the same as number = number * 5;
number /= 5; // the same as number = number / 5;
console.log(number);
The addition assignment can also be used with strings! Let me show you:
let string = 'Hello';
string += ', I am John.';
console.log(string);
That's it when it comes to assignment operators—you're basically a pro at them! 😊
"Please login to view comments"
Subscribing gives you access to the comments so you can share your ideas, ask questions, and connect with others.
How did you manage to remove the blur property and reach here?
Upgrading gives you access to quizzes so you can test your knowledge, track progress, and improve your skills.
By logging in, you'll unlock full access to this and other free tutorials on JSM Pro.
Why? Logging in lets us personalize your learning experience, track your progress, and keep you in the loop with new workshops, coding tips, and platform updates.
You'll also be the first to know about upcoming launches, events, and exclusive discounts.
No spam—just helpful content to level up your skills.
If that sounds fair, go ahead and log in to continue →
Enter your name and email to get instant access
##Looks like we found a thief monkey By the way, I liked the trick how you reached till here. You have a good sense of humor. You will improve a lot if you join our course with this passion.
var
(function-scoped, outdated)let
(block-scoped, modern and recommended)const
(block-scoped, cannot be reassigned)_
, or $
let let = 5;
is invalid)myVar
and myvar
are different)string
, number
, boolean
, null
, undefined
, bigint
, symbol
Objects
, Arrays
, Functions
Subscribing gives you access to a brief, insightful summary of each lecture to stay on track.
00:00:00 And the last but not the least category of operators in JavaScript are the assignment operators, used to assign and manipulate values within variables.
00:00:11 An assignment operator assigns a value to its left operand based on the value of its right operand.
00:00:18 Would you believe me if I told you that you not only know what an assignment operator is, but that you've been using it this whole time?
00:00:25 The simplest form of an assignment operator is the equal sign, and it's used to assign values to variables.
00:00:33 Cons number is equal to 5. This right here is an assignment operator.
00:00:38 We can also combine the assignment operator with one of the arithmetic operators to perform an operation and assignment in one step.
00:00:46 That would look something like this.
00:00:48 like number plus equal to 5. This is the same as number is equal to number plus 5. And the same thing goes for all of the other arithmetic operators.
00:00:59 You can just combine them.
00:01:00 Minus equal to, times equal to, or divided by equal to, which is the same as number equal to, number, and then that specific operation is performed.
00:01:10 And of course, if you want to combine these different assignment operators, you have to first declare this variable as let,
00:01:16 because only then you can reassign it.
00:01:19 The addition assignment can also be used with strings.
00:01:22 Let me show you how that works.
00:01:24 You can define let string and make it equal to hello.
00:01:28 Then, if you console log the string, of course, you know what you expect.
00:01:32 Hello.
00:01:33 But now, you can say that string plus equal to a string of comma, I am Adrian.
00:01:41 And if you save it, it's going to say, hello, I am Adrian.
00:01:44 So this works not only for the numbers, but for the strings too.
00:01:49 But this is not used as often now that we have the template strings, because now you can just easily do something like this,
00:01:56 console log, put it in a template string, use this as a variable, and then add it right here directly.
00:02:05 It will look something like this.
00:02:07 String iamadrian.
00:02:09 It has the same output, but you didn't need to use that assignment operator.
00:02:13 Pretty cool, right?
00:02:14 And that's it when it comes to assignment operators.
00:02:17 you're already a pro.
00:02:18 Not only is this the end of the assignment operators, but it's the end of the entire operators module.
00:02:25 You learn the basics of arithmetic, comparison, logical, and assignment operators, as well as how the equality works within JavaScript.
00:02:34 But the next module is where things get interesting.
00:02:37 The next module will allow you to use all of these operators to make your code actually do some cool things.