Javascript Goal Clarity

Using Javascript has become more complex and powerful over the past five years. One of the aspects of this kind of functional programming that I come across, especially the features of Javascripts, is how to do what is going on clearly or through comments or code. Often this kind of code takes time to decrypt, even if you understand the prototype, first-class functional Javascript method. Any thoughts or methods in order to clearly understand what your code does and how in Javascript?

I asked this question elsewhere but did not get a lot of answer.

+3
source share
7 answers

- , , "" JavaScript . , , . .

, JavaScript, , .., , . , #/Java/++/VB/ .. JavaScript - , , , - , ..

, : " JavaScript -, ?" - JavaScript - JavaScript, , "" .

, , JavaScript, ( , ) :

// comments are not included *on purpose* for illustrating 
// my point about the need for language knowledge
function copy(obj) {
  return new (function(o) {
    for(var property in o) {
      if(o[property].constructor == Array) {
        this[property] = [];
        for(var i = 0; i < o[property].length; i++) {
          this[property][i] = new arguments.callee(o[property][i]);
        }
      } else if(o[property].constructor == Object) {
        this[property] = new arguments.callee(o[property]);
      } else {
        this[property] = o[property];
      }
    }
  })(obj);
}

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


: , , , , . , , . JavaScript, - .

- , , JavaScript, , . , , ( # Java) this , , JavaScript.

+3

- JavaScript . jQuery, , .

JavaScript

+1

:

  • . JavaScript {key: {function}} . .
  • . jQuery, .. - , API. - JavaScript-, .

, . , , <input> ( ), . , .

JavaScript - , .js , .

+1

, , jQuery, JavaScript. , , . , , JavaScript . , , . {{function() {... .

0

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

0

@

, , " " javascript (). " " " " .. , , JavaScript.

, , , Javascript, , .

0
  • . , - IDE ( NetBeans WebStorm ) JS Beautyfier ( - "" ).

  • . , , , , , , .

  • , IDE . , var module = ( function () { ... } )(); Module = function () { ... }; Module.prototype.method1 = function () { ... };

  • vars , .

  • this . - . function Car() { _car = this; _car.accelerate = function () { ... }; }

  • - , , IE8 , jQuery . , .

  • JS Doc, - , IDE - .

  • Write for debug, . ..: function() { return { , , , .

  • eval, , eval setTimeout addEventListener.

0

Source: https://habr.com/ru/post/1699429/


All Articles