JavaScript -Functions

1.what is function?
set of instruction perform specific task can be called multiple times optionally takes input as** parametters** and optionally returns values.
Functions significantly enhance code reusability by encapsulating specific functionaliti…


This content originally appeared on DEV Community and was authored by Dharshini E

1.what is function?
set of instruction perform specific task can be called multiple times optionally takes input as** parametters** and optionally returns values.
Functions significantly enhance code reusability by encapsulating specific functionalities into self-contained blocks.
This allows the same block of code to be invoked **multiple times **from different parts of a program.
function is a keyword.

syntax:

function functionName(parameter1, parameter2, ...) {

  return value; // Optional return statement
}

functionName() -function calling statement
{ } - function definition

.log() - is a function , its created by javascript perdefined functions or inbuilt funtion.
example :

console.log("welcome!");

typeof - its used to find "which type of data is given".
example:

let name ="dharshini";
console.log(typeof name);

BigInt - datatype
BigInt variables are used to store big integer values that are too big to be represented by a normal JavaScript Number.
example:

let y = 9999999999999999n;

What is return ?
The return statement stops the execution of a function and returns a value.

function myFunction(name) {
  return "Hello " + name;
}
console.log(myFunction("dharshini")); // Hello dharshini

prompt()
In JavaScript, the prompt() method is a built-in function used to display a dialog box that prompts the user for input. This dialog box includes a message, a text input field, and "OK" and "Cancel" buttons.

Syntax :

result = prompt(message, defaultValue);

alter()
In JavaScript, alert() is a global function used to display a modal dialog box with a specified message and an "OK" button. This dialog box pauses the execution of the script until the user clicks "OK".
example:

alert(" please enter vaild input");

happy codding!


This content originally appeared on DEV Community and was authored by Dharshini E


Print Share Comment Cite Upload Translate Updates
APA

Dharshini E | Sciencx (2025-08-07T03:21:28+00:00) JavaScript -Functions. Retrieved from https://www.scien.cx/2025/08/07/javascript-functions-2/

MLA
" » JavaScript -Functions." Dharshini E | Sciencx - Thursday August 7, 2025, https://www.scien.cx/2025/08/07/javascript-functions-2/
HARVARD
Dharshini E | Sciencx Thursday August 7, 2025 » JavaScript -Functions., viewed ,<https://www.scien.cx/2025/08/07/javascript-functions-2/>
VANCOUVER
Dharshini E | Sciencx - » JavaScript -Functions. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/08/07/javascript-functions-2/
CHICAGO
" » JavaScript -Functions." Dharshini E | Sciencx - Accessed . https://www.scien.cx/2025/08/07/javascript-functions-2/
IEEE
" » JavaScript -Functions." Dharshini E | Sciencx [Online]. Available: https://www.scien.cx/2025/08/07/javascript-functions-2/. [Accessed: ]
rf:citation
» JavaScript -Functions | Dharshini E | Sciencx | https://www.scien.cx/2025/08/07/javascript-functions-2/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.