Live
Black Hat USADark ReadingBlack Hat AsiaAI Business5 AI-powered consulting startups to watchBusiness InsiderWhat Teens Are Doing With Those Role-Playing Chatbots - The New York TimesGoogle News: AIOCSF explained: The shared data language security teams have been missingVentureBeat AIdark ilanlesswrong.comMicrosoft Is Going Multi-Model with Copilot. Does the Enterprise King Win Again? - The Motley FoolGNews AI MicrosoftShow HN: Running local OpenClaw together with remote agents in an open networkHacker NewsA folk musician became a target for AI fakes and a copyright trollThe Verge AIWhat Teens Are Doing With Those Role-Playing ChatbotsNYT TechnologyChicken-Free Egg Whiteslesswrong.comDesktop Canary v2.1.48-canary.35LobeChat ReleasesPlease someone recommend me a good model for Linux Mint + 12 GB RAM + 3 GB VRAM + GTX 1050 setup.Reddit r/LocalLLaMABest Artificial Intelligence Stocks To Add to Your Watchlist - April 4th - MarketBeatGoogle News: AIBlack Hat USADark ReadingBlack Hat AsiaAI Business5 AI-powered consulting startups to watchBusiness InsiderWhat Teens Are Doing With Those Role-Playing Chatbots - The New York TimesGoogle News: AIOCSF explained: The shared data language security teams have been missingVentureBeat AIdark ilanlesswrong.comMicrosoft Is Going Multi-Model with Copilot. Does the Enterprise King Win Again? - The Motley FoolGNews AI MicrosoftShow HN: Running local OpenClaw together with remote agents in an open networkHacker NewsA folk musician became a target for AI fakes and a copyright trollThe Verge AIWhat Teens Are Doing With Those Role-Playing ChatbotsNYT TechnologyChicken-Free Egg Whiteslesswrong.comDesktop Canary v2.1.48-canary.35LobeChat ReleasesPlease someone recommend me a good model for Linux Mint + 12 GB RAM + 3 GB VRAM + GTX 1050 setup.Reddit r/LocalLLaMABest Artificial Intelligence Stocks To Add to Your Watchlist - April 4th - MarketBeatGoogle News: AI
AI NEWS HUBbyEIGENVECTOREigenvector

What is a Function? Simple Explanation with Examples

DEV Communityby subashApril 4, 20262 min read2 views
Source Quiz

what is function ? 1.function is a block of code that perform specific task. *block of code is a group of instruction to perform specific task. 2.Instead of writing the same code again and again, you can write it once inside a function and reuse it whenever needed. EXAMPLES; function square(number) { return number * number; } *In this case function is keyword, square is the function name what we named, inside the parentheses have parameters if we want to use so many parameters inside the parentheses then we must separate each of them with commas. *if we want to execute this function, then we should call this name of function, this function name is square so we call this like square() or if we want to put arguments then we should call this like square(23) in this case what was happened is y

what is function ?

1.function is a block of code that perform specific task. block of code is a group of instruction to perform specific task. 2.Instead of writing the same code again and again, you can write it once inside a function and reuse it whenever needed.

EXAMPLES;

function square(number) { return number * number; }*

In this case function is keyword, square is the function name what we named, inside the parentheses have parameters if we want to use so many parameters inside the parentheses then we must separate each of them with commas.

if we want to execute this function, then we should call this name of function, this function name is square so we call this like square() or if we want to put arguments then we should call this like square(23) in this case what was happened is you imagine number(parameter) is the variable and arguments is variable value , what the value(arguments) we give while callback that value will store in variable(parameters)

for example: let calculation = square(2) --- => this returned number * number console.log (calculation) Then final output is --- 4 (22 --- => numbernumber)*

Inside calculation have function that entire function returned (number * number) right then we print the variable calculation then output is 4 because my arguments is 2*2 =>4

REFERENCE WEBSITE; https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions

Was this article helpful?

Sign in to highlight and annotate this article

AI
Ask AI about this article
Powered by Eigenvector · full article context loaded
Ready

Conversation starters

Ask anything about this article…

Daily AI Digest

Get the top 5 AI stories delivered to your inbox every morning.

Knowledge Map

Knowledge Map
TopicsEntitiesSource
What is a F…DEV Communi…

Connected Articles — Knowledge Graph

This article is connected to other articles through shared AI topics and tags.

Knowledge Graph100 articles · 164 connections
Scroll to zoom · drag to pan · click to open

Discussion

Sign in to join the discussion

No comments yet — be the first to share your thoughts!

More in Products