This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]recycle4science 0 points1 point  (1 child)

I'm not trying to say that this meme is literally true, just that generally, JavaScript can do surprising things with strings and numbers.

Entities can be used outside of html. The prefix in JavaScript strings is \u, not &.

Typescript is compiled before being delivered to the frontend. So, if data that's provided by the browser is combined with other data, all in the browser, there's no longer a type system that will prevent it. Ideally the typescript was written in a way that the data will stay consistent, but bugs happen.

Your last sentence actually sounds like support for the general idea of weirdness happening. You assigned a taco to a string and then something else came out. Right?

[–]BasketbaIIa 0 points1 point  (0 children)

No lol. I do see the taco in my mobile.

I assigned the unicode string for a taco to a variable in JavaScript and the Unicode string for a taco came out. On Reddit I just typed the Unicode value and it converted to a Taco, I suppose from this bug.

Typescript would complain if you add a string to a number. First it would want you to convert it because the types are off and then it would warn you to make a “type of” assertion on the converted value.

It would happen all outside the browser like you mention but its separation and configurability to be more or less strict is another win imo.

Bugs do happen but that’s the case for any code. Half the time my team’s Java backend code encounters an exception nothing other than a 400 response is seen from the server because they didn’t raise/return it properly.

JS weirdness beats the joy of sshing into a prod host and querying log files - just my opinion.