Best practices for developing JS?

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.

+5
source share
4 answers

A lot can be said about this.

-, , , . . JavaScript .

JavaScript , , , , . JavaScript , , , .

- . , . . - ( , ). , , , . , . , . , , HTML, - . .js .

, . . .

JavaScript . ( , , ..).

, jQuery, , . (, DOM, Ajax, JSON).

. QUnit, JavaScript. .

, JavaScript. . ( , ) ( , , ).

Ajax , RESTful . Ajax - . , - .

+3

. , , - . , / - .

/; , . , :)

UPDATE

, , , " ". ;

+3

.

" , JS-, , JS:("

, .

, . , socket.io - AJAX.

-, Javascript , Java, OOP, .

Javascript, , , , , .

0

, JS Framework ( JQuery), ( , , , ), , , . , JavaScript HTML-. JQuery CSS- HTML- (, ..). JQuery: http://docs.jquery.com/Tutorials:How_jQuery_Works

In any case, understanding the principles of JavaScript is very important, and for this I recommend reading a good book on the subject. Personally, I find JavaScript programming using jQuery very satisfactory due to the functionality of the language. I also recommend O'Reilly JavaScript: The Good Parts.

0
source

All Articles