Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

basics
functions
javascript

Javascript functions

Educative Answers Team

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring