Back to articles
What is a Function? Simple Explanation with Examples

What is a Function? Simple Explanation with Examples

via Dev.tosubash

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 calculati

Continue reading on Dev.to

Opens in a new tab

Read Full Article
3 views

Related Articles