javascript muito básico.

  1. variáveis

    var varString = "abc";
    var varNumber = 123;
    var varArray = ["abc",123];
  2. função

    var varFunction = function ()
    {
    code code code
    ;
    };
  3. controle de fluxo

    // if-else
    if (condition) {
    code code code
    ;
    } else if {
    code code code
    ;
    } else {
    code code code
    ;
    }
    //while
    while (condition) {
    code code code
    ;
    }
    //do-while
    do {
    code code code
    ;
    } while (condition)
    //for
    for (initial ; condition ; incrementor) {
    code code code
    ;
    }
  4. Matemática

    var NumberSeven = Math.floor(7.14);
    var RandomBetweenZeroAndOne = Math.randome();
    //A random number between 1 and 10
    var randomNumber = Math.floor(Math.random() * 9 + 1);
  5. oo

    //Literal notation
    var varObject = function () {
    this.property1= property1;
    this.property2 = property2;
    this.method = function () {
    code code code
    ;
    code code code
    ;
    }
    };

    //Constructor notation
    var varObject = new Object();
    varObject
    .property1 = property1;
    varObject
    .property2 = property2;
    varObject
    .method = function () {
    code code code
    ;
    code code code
    ;
    }