What is Assignment Operators in JavaScript and what is work and what it's used in JavaScript? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8

What is Assignment Operators in JavaScript and what is work and what it's used in JavaScript?

25th Jan 2020, 7:29 AM
♡╣Hüsñāíñ Ālí╠♡
♡╣Hüsñāíñ Ālí╠♡ - avatar
16 Answers
+ 6
in simple words, the assignment operator works like this: when declaring a variable (using special words [var, let, or const]), space is reserved for data in the computer's memory area. but there is no data yet. this can be compared to a room and an empty box. a room is all the computer's memory, and a box is your variable. as long as there is no variable (you haven't declared it), the room is empty. and now comes the crucial moment... you have declared a variable! [let userName;] (a box was brought into the room). but your variable doesn't matter yet. it is empty (the box is empty, but"userName"is written on top of it). but from now on, the computer sees your variable. he can now manipulate her. if you try to output its value at this point, javascript will give you the answer: "undefined". to assign a value to a variable, use the "= " assignment operator. userName = "Johnny".you put the text (string value "Johnny")in the box (pc memory).
25th Jan 2020, 8:24 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 8
The assignment operator is normally known as the equal sign (=). It is for Assigning a value to a variable eg var name="name"; Happy coding 😉 Keep coding
25th Jan 2020, 7:35 AM
Alfred Juma
Alfred Juma - avatar
+ 6
Thank you 😊
25th Jan 2020, 7:45 AM
♡╣Hüsñāíñ Ālí╠♡
♡╣Hüsñāíñ Ālí╠♡ - avatar
+ 5
Is it your homework?
25th Jan 2020, 7:31 AM
Oma Falk
Oma Falk - avatar
+ 4
Just follow your course tutorial and keep practicing. Watch youtube vids of what you want about Js. Do google research.
25th Jan 2020, 7:44 AM
Alfred Juma
Alfred Juma - avatar
+ 4
Thank you so much for this detail . Now I understand what Assignment Operators are doing.😊
25th Jan 2020, 8:30 AM
♡╣Hüsñāíñ Ālí╠♡
♡╣Hüsñāíñ Ālí╠♡ - avatar
+ 3
No, I am learning JavaScript and am confused about assignment operators. I don't understand what's it works and uses.
25th Jan 2020, 7:33 AM
♡╣Hüsñāíñ Ālí╠♡
♡╣Hüsñāíñ Ālí╠♡ - avatar
+ 3
And other operators uses?
25th Jan 2020, 7:39 AM
♡╣Hüsñāíñ Ālí╠♡
♡╣Hüsñāíñ Ālí╠♡ - avatar
+ 3
Recently I started a JavaScript course.
25th Jan 2020, 7:41 AM
♡╣Hüsñāíñ Ālí╠♡
♡╣Hüsñāíñ Ālí╠♡ - avatar
+ 3
maybe it was a bit confusing, but I tried to avoid 😁 Successful coding!
25th Jan 2020, 8:35 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 3
Thank you 😊
26th Jan 2020, 8:56 AM
♡╣Hüsñāíñ Ālí╠♡
♡╣Hüsñāíñ Ālí╠♡ - avatar
+ 3
I'm confused about the part of the question which says "what is work?"
27th Jan 2020, 4:17 AM
Sonic
Sonic - avatar
+ 2
Greetings! I dare say that you probably have not fully completed the JavaScript training course in this app. perhaps there you can find the answer to your question
25th Jan 2020, 7:36 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 2
thank you, I've already seen it. isn't one assignment statement enough for you? do you need more???
25th Jan 2020, 7:44 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 2
let userName; console.log(userName); // undefined userName = "Johnny"; console.log(userName) // Johnny
25th Jan 2020, 8:28 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 1
for assigning a value to a variable(var, let, const)
25th Jan 2020, 8:17 PM
mohammadreza
mohammadreza - avatar