I am a web developer. I used to be a PHP programmer for several years, but now for about two years I am a Java developer. But regardless of the server-side programming language, I still use JS. But, unfortunately, I can’t say that I can write JS code.
The logic seems fragile and scattered throughout the code, on different pages. I mean, I use part of the logic on page A, then another part on page B, etc. Etc. And the js code is getting a mess :(
I am trying to move general logic to JS files. But at the same time, I write code on page A, then on page B, on page C. I use some kind of ajax callback in which I call the function defined on page A and so on and so on.
I mean, there are a lot of new JS frameworks today, but I'm afraid to use them, because I'm afraid of JS :(
So, are there any recommendations for writing JS code?
UPD: Guys, don't get me wrong. The problem for me is not to learn the language, but to use it correctly. JS is very different from PHP / Java, and also means that other approaches should be used?
PS I read JavaScript: good details, and I know some JS tricks and warnings. But information about best practices for using AJAX and other materials for client-server interaction is not enough.