0

I am new to JS, and JS syntax is definitely confusing to me as I'm used to other languages instead.

const x = 5;
x.yy = 3;
console.log(x.yy); // undefined

How is x.yy = 3; a valid syntax?

and why is x.yy undefined when x.yy =3; took in place?

  • See [this answer](https://stackoverflow.com/a/9110389/5648954) from one of the dupes above, that explains your situation, just with a string (rather than an number) – Nick Parsons Jul 11 '21 at 03:24
  • On a side note . Try reading "Javascript the good parts" book – Ramesh Jul 11 '21 at 03:36

0 Answers0