Comrades, please consider. A friend of mine saw (==) instead of (===) in my php code and now constantly grumbles at me for the fact that== is a mortal sin and should be crossed out as obsolete in all documentation, period, but I don’t have the right to be called a developer and deserve respect because I used== in the code. In my case, in my opinion, it is more convenient to use== because the functions whose results I compare cannot return anything left that can break the logic. But at the same time, I can't be sure whether the function will give me a number in string or int format, and to avoid unnecessary conversion steps, I just use==. (But my interlocutor somehow doesn’t give a damn about this argument)

Lord Seniors, please judge. Am I an incompetent specialist or is my friend an aggressive buzzer ( this is not a mate, google it if this word confused you)? Is it normal to use (==) when the architecture allows it, or is it completely wrong? And quote -

I generally think that== should be marked in red in developer.mozilla as a deprecated syntax.

I'm ready to strangle you for==

Another question about JS -the same character aggressively attacked me because I was in my code instead of modern

//Function Expression
const foo= ()=> {...}


//Function Declaration
function foo() {...}

I understand that ala is modern and gives some advantages, but it was more customary to just write function () and I didn’t think about it, and the code in some unknown way even worked on such "junk". Did my interlocutor have the right to declare that I am making an extremely gross mistake and consider me incompetent? It seems to me that in this dispute, in part, both are wrong, but my opponent, whom I once pushed into IT, is no longer right because he aggressively ran into me because of normal things.

So I think the same, but his argument is based on the fact that function pop-ups are somehow bad and this is the old syntax, and comparing through== can "break the code because lalalya, but what if you return something 0 and this is already will not be 0 but false", but the fact that sometimes it can be convenient for him somehow on the side. I need an iron argument to intelligibly explain just the fact that these are different full-fledged constructions that are equal in importance and it cannot be said that== is impossible and=== is necessary.

Alexander Borysenko2022-01-15 08:58:33

See. If you are making a business card site or a small landing -yes, you can probably allow== and function declaration. But for large sites, applications, this is no longer valid. With=== you know exactly what you have, exactly control the type, and in case of its invalid value, you can immediately correct the logic and code. This gives more confidence in what exactly you are transmitting and what you are operating at the moment. And not so that null, 0, '', false will arrive, and then how the map will fall .... Moreover, strict comparison and typing gives greater application security.

Алексей Шиманский2022-01-15 10:43:17

Again, for the reason that you can’t slip something superfluous and execute unwanted code .. Therefore, in large applications, they generally prefer to deal with typing (typeScript and the like) .... So=== -reliability, control and safety.== -complete lack of control.... With function declaration, too -taking into account the fact that now everyone is switching to classes -there is no need for them at all. In a modular approach, you can safely and beautifully write through function expression. Some functions are even more concise. And I didn’t see function declaration in modules.

Алексей Шиманский2022-01-15 10:43:20

So yes, atavism in most cases ........ So you are looking for confirmation of your words, but in general you are rather wrong. I emphasize once again: if a business card and the simplest site with a minimum of JS, you can write at least noodle code. In serious software -it is better not to use this

Алексей Шиманский2022-01-15 10:43:31