Yahoo India Web Search

Search results

  1. A JavaScript function is a block of code designed to perform a particular task. A JavaScript function is executed when "something" invokes it (calls it). Example. // Function to compute the product of p1 and p2 function myFunction (p1, p2) { return p1 * p2; } Try it Yourself »

  2. Aug 13, 2024 · A function in JavaScript is a reusable block of code that performs a specific task. You define it once, and then you can run (orcall”) it whenever you need that task done in your program. A JavaScript function runs when it is “called” by some part of your code. Syntax: The basic syntax to create a function in JavaScript is shown below.

  3. Sep 9, 2024 · A function in JavaScript is similar to a procedurea set of statements that performs a task or calculates a value, but for a procedure to qualify as a function, it should take some input and return an output where there is some obvious relationship between the input and the output.

  4. JavaScript functions are defined with the function keyword. You can use a function declaration or a function expression.

  5. This tutorial introduces you to JavaScript functions that structure your code into smaller reusable units.

  6. Jun 30, 2022 · A function is a block of reusable code written to perform a specific task. You can think of a function as a sub-program within the main program. A function consists of a set of statements but executes as a single unit. In JavaScript, we have some browser built-in functions like alert (), prompt (), and confirm ().

  7. Aug 25, 2024 · Generally speaking, a function is a "subprogram" that can be called by code external (or internal, in the case of recursion) to the function. Like the program itself, a function is composed of a sequence of statements called the function body. Values can be passed to a function as parameters, and the function will return a value.

  8. Functions are the main “building blocks” of the program. They allow the code to be called many times without repetition. We’ve already seen examples of built-in functions, like alert(message), prompt(message, default) and confirm(question). But we can create functions of our own as well. To create a function we can use a function declaration.

  9. Functions are the basic building block of JavaScript. Functions allow us to encapsulate a block of code and reuse it multiple times. Functions make JavaScript code more readable, organized, reusable, and maintainable. Syntax: function <function-name>(arg1, arg2, arg3,...) //write function code here .

  10. Jul 15, 2017 · A function is a JavaScript procedurea set of statements that performs a task or calculates a value. To use a function, you must define it somewhere in the scope from which you wish to call it. See also the exhaustive reference chapter about JavaScript functions to get to know the details.