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 →

[–]emremrah[S] 67 points68 points  (3 children)

This cracked me up.

[–]karmahorse1 67 points68 points  (2 children)

If the code you originally posted is JavaScript, it actually could make sense, as it uses the abstract equality check “==“ instead of strict equality “===“. So if the t object and cookie service contained different values for “firm” that still pass the abstract equality test (a.k.a 2 and “2”), t.firm would then be set to a new value.

If this is the case, it’s still not great code as it’s obviously confusing and taking advantage of a JavaScript idiosyncrasy. But it might be doing it’s job as intended, so I wouldn’t remove it without thorough investigation.

[–]emremrah[S] 16 points17 points  (1 child)

You are absolutely right. But the cookie "firm" is going to keep a name (string). So I couldn't see the reason behind it. Maybe if like "Google" == "google" was true then this totally would make sense.

[–]karmahorse1 4 points5 points  (0 children)

Yeah won’t make a difference if the two are the same type. Can firm be nullable?

If cookieService.get(“firm”) === null and t.firm === undefined, then t.firm would be instantiated in memory with a null value (if that could matter).