Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Functions | Section
JavaScript Essentials for React Native Development

bookFunctions

Свайпніть щоб показати меню

A function in JavaScript is a reusable block of code that performs a specific task. You define a function using the function keyword, followed by a name, a list of parameters inside parentheses, and a block of code called the function body inside curly braces.

12345678
// Function declaration function greet(name) { return "Hello, " + name + "!"; } // Calling the function const message = greet("Sam"); console.log(message); // Output: Hello, Sam!
copy

The parameters are placeholders for values you provide when calling the function. In the example above, name is a parameter. The function body contains the code that runs when the function is called. Inside the body, you can use a return statement to send a value back to the place where the function was called. If you do not include a return statement, the function returns undefined by default.

When you call a function, you provide arguments, which are the actual values for the parameters. In the code sample, the function greet is called with the argument "Sam". The function returns the string "Hello, Sam!", which is stored in the variable message and then printed to the console.

question mark

What does a function do?

Виберіть правильну відповідь

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 4

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Секція 1. Розділ 4
some-alt