Dev4Hub
TutorialsRoadmapReviewNotesCode Editor
Sign inSign up
  • Python
  • HTML
  • CSS
  • JavaScript
  • SQL
Your progress0 / 4
search
school

JS Basics

  • 1JS Introduction
  • 2JS Variables
  • 3JS Functions
menu_book

JS DOM

  • 1DOM Introduction
Tutorialschevron_rightJavaScript Tutorialchevron_rightJS Functions

JS Functions

format_list_numberedLesson 3 of 4schedule1 min readview_agenda1 sectionauto_awesomeAI tutor ready
01

JavaScript Functions

A JavaScript function is a block of code designed to perform a particular task. It is executed when "something" invokes it.

Example

function add(a, b) {
  return a + b;
}
console.log(add(3, 4));

Output

7
Try it Yourself »
arrow_back PreviousJS VariablesNext arrow_forwardDOM Introduction

Dev4Hub

Learn coding with hands-on tutorials, examples and quizzes — covering Python, HTML, CSS, JavaScript, SQL and more.

Tutorials

  • Python
  • HTML
  • CSS
  • JavaScript
  • SQL

Tools

  • Code Editor
  • All Tutorials
© 2026 Dev4Hub. Inspired by the W3Schools learning model.