O GoConqr está de visual novo! Conte para nós o que você achou.

Mapa mental

Function

Nguyet Huynh JavaScript Beginner Inglês

Conteúdo do mapa

Function

  1. Definition

    • functionName(parameters){ code to execute }
    • var x = function(parameters) { code to execute }
    • EX: addNumber(a, b){ return a + b) }; x=addNumber(1,2)
  2. Parameter

    • Parameter vs argument
      • Paramter: names listed in function definition
      • Arument: real value passed to function
    • Parameter rules
      • not specify type
      • not perform type check on passed argument
      • not check number of argument received
    • Argument object
      • use when: too many arguments (more than declared)
      • arguments.length; arguments[i]
    • Cach truyen gtri
      • by value = arguments
      • by reference = object
  3. Closures

    • Global variables
      • lifetime: as long as application lives
      • all variable declare without var --> global variable (even if inside function)
    • Local variables = closure
  4. Invocation (goi ham)

    • goi giong o EX phan definition
    • Method of object: objectName.functionName();
    • function constructor
      • function myFunction(ar1, arg2){ this.firstName = arg1; this.lastName = arg2;}
      • var x = myFunction("John", "Joe"); x.firstName;
    • use function method
      • call()
        • var number; function myFunction(a,b){ return a*b;} number = myFunction.call(number, 10, 2)
      • apply()
        • var number, myArray; function myFunction(a,b){ return a*b;} myArray = [10,2]; number = myFunction.apply(number,myArray)
  5. Recursion = De quy

    • Syntax
      • Loop: var factor = function(number) { var result = 1; var count; for (count = number; count > 1; count--) { result *= count; } return result; }; console.log(factor(6)); // 720
      • Recursion: var countdown = function(value) { if (value > 0) { console.log(value); return countdown(value - 1); } else { return value; } }; countdown(10);
    • feature
      • call itself
      • 10 times slower than loop
      • s.times solve problem easier than loop
    • use for
      • iterative branching
      • such as: fractal math, sorting, or traversing the nodes of complex or non-linear data structures

Informações

Descrição
Beginner JavaScript Mapa Mental sobre Function, criado por Nguyet Huynh em 12-12-2015.
Criado por
Nguyet Huynh
Visualizações
0
Avaliação

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?