Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

basics
functions
javascript

Javascript functions

Educative Answers Team

Functions are a kind of subroutine that performs a specific task. Like every other programming language, JavaScript has its own rules for declaring functions. Some syntax may seem familiar; however, there are a few things to notice.

Syntax

The function keyword is placed before the name of the new function to indicate that a new function is being declared. Curly braces {} are used to indicate the function’s body, like most other languages.

function HelloWorld(args){
    // your code
}
svg viewer
Parts of a function

Code

Console

Anonymous function

In JavaScript, we can make functions without a name called anonymous functions. In the example below, the variable HelloWorld can lose the function declaration and be replaced by any other value.

Console

Lambda Functions

Lambda functions are similar to anonymous functions, but they have more flexible features and syntax. An arrow function is another of this type of function.

var functionName = (parameters) => // function body
Console

RELATED TAGS

basics
functions
javascript
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring