“Funkcja strzałek w JavaScript” Kod odpowiedzi

Funkcje strzałek w ES6

let func = (a) => {}         // parentheses optional with one parameter
let func = (a, b, c) => {} // parentheses required with multiple parameters
Outrageous Ostrich

Podstawowa funkcja strzałek JavaScript

const power = (base, exponent) => {
    let result = 1;
    for (let count = 0; count < exponent; count++) {
      result *= base;
    }
    return result;
  };
The Arborist

Jak zrobić spółkę funkcji JavaScript

multiplyfunc = (a, b) => { return a * b; }
TechWhizKid

funkcja strzałki JavaScript

hello = () => {
  return "Hello World!";
}
Ankur

Funkcja strzałek w JavaScript

// Arrow functions let us omit the `function` keyword.
// Here `long_example` points to an anonymous function value.
const long_example = (input1, input2) => {
    console.log("Hello, World!");
    const output = input1 + input2;

    return output;
};

// If there are no braces, the arrow function simply returns the expression
// So here it's (input1 + input2)
const short_example = (input1, input2) => input1 + input2;

long_example(2, 3); // Prints "Hello, World!" and returns 5
short_example(2, 5);  // Returns 7

// If an arrow function only has one parameter, the parentheses can be removed.
const no_parentheses = input => input + 2;

no_parentheses(3); // Returns 5
Ali Salman

Funkcja strzałek w JavaScript

let numbers = (x, y, z) => (x + y + z) * 2;
console.log(numbers(3, 5, 9))
//Expected output:34
Ariful Islam Adil(Code Lover)

Odpowiedzi podobne do “Funkcja strzałek w JavaScript”

Pytania podobne do “Funkcja strzałek w JavaScript”

Więcej pokrewnych odpowiedzi na “Funkcja strzałek w JavaScript” w JavaScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu