Actually, your 3rd point is wrong. I dont know how Typescript would behave, but as for JS what You do in second example is assigning variable user to new object. And You loose properties set by User constructor
It's not only about Typescript typing; TS is right about changing the type of your variable because you're assigning a completely new value to it. Doesn't matter if it's an User object, or a string or a number, she the assignment, user is an object with the specified values in it. The User prototype is lost.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Actually, your 3rd point is wrong. I dont know how Typescript would behave, but as for JS what You do in second example is assigning variable user to new object. And You loose properties set by User constructor
You’re absolutely right! I forgot to type it! Will update the gist shortly. Thanks for the catch
It's not only about Typescript typing; TS is right about changing the type of your variable because you're assigning a completely new value to it. Doesn't matter if it's an User object, or a string or a number, she the assignment,
user
is an object with the specified values in it. The User prototype is lost.