In JavaScript, a function is a set of statements that performs a specific task and returns a result, helping to avoid code repetition. Functions can be built-in or user-defined, created using the 'function' keyword followed by the function name and parameters. The document also provides a syntax example for defining a function and mentions Immediately Invoked Function Expressions (IIFE).
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
2 views
JSFunctionNotes
In JavaScript, a function is a set of statements that performs a specific task and returns a result, helping to avoid code repetition. Functions can be built-in or user-defined, created using the 'function' keyword followed by the function name and parameters. The document also provides a syntax example for defining a function and mentions Immediately Invoked Function Expressions (IIFE).
Functions:->A function in javascript is a collection/set of some statement which
takes some input, doing a specific task/computation and displaying/return the result/output. The objective of writing a function is to avoid writing of same code again and again to achieve the same objective for different input i.e., to avoid repetition of code. ->JavaScript has number of built-in functions. But, JavaScript allows a programmer to create a user-defined functions. ->"function" is the keyword which is used to create a function in JavaScript. ->To craete a function is JavaScript, firstly write "function" keyword and the function name followed by a sepace i.e., function keyword and function should be separated by a space. There will be a parenthesis just after function name which consists of parameters. The function body will be inside curly braces which is given just after parenthesis. ->Syntax for creating a function in JavaScript :
Python Advanced Programming: The Guide to Learn Python Programming. Reference with Exercises and Samples About Dynamical Programming, Multithreading, Multiprocessing, Debugging, Testing and More