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?

2
  • See this answer from one of the dupes above, that explains your situation, just with a string (rather than an number) Commented Jul 11, 2021 at 3:24
  • On a side note . Try reading "Javascript the good parts" book Commented Jul 11, 2021 at 3:36

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.