+ 1

*HELP* In Javascript , What does Uncaught ReferenceError: Invalid left-hand side in assignment MEAN??

I tried changing the value of a variable which was in another function... https://code.sololearn.com/W2Fpuok7s4VJ/?ref=app

5th Nov 2019, 12:12 PM
Siphesihle Bomela
Siphesihle Bomela - avatar
4 Respostas
+ 1
Trinity [Exams] In a regular assignment operation, whatever is to the left of = operator is said "left-hand side" (short as LHS), and whatever is to the right of = operator is said "right-hand side" (short as RHS). The error message tells you that `myfunction(this.a)` (the LHS) is not a good candidate to accept the value 20 (the RHS). I think this is because the LHS here is a function, which usually returns something rather than accepting something (being assigned a value). Is this the whole part of the code?
5th Nov 2019, 12:48 PM
Ipang
+ 1
I just created a new code to show the error
8th Nov 2019, 6:33 PM
Siphesihle Bomela
Siphesihle Bomela - avatar
+ 1
Trinity [Exams] However it is possible to assign a value to an object's attribute (property). So we need to use the object rather than the object constructor function (myFunction). https://www.sololearn.com/learn/JavaScript/1152/ function myFunction(n) { this.a = n; } window.onload = function() { var obj = new myFunction(42); console.log(obj.a); // 42 obj.a = 20; console.log(obj.a); // 20 obj.a *= 100; console.log(obj.a); // 2000 }
8th Nov 2019, 9:08 PM
Ipang
+ 1
Ipang Thank YOU VERY MUCH!!
8th Nov 2019, 9:11 PM
Siphesihle Bomela
Siphesihle Bomela - avatar