1.Function in JavaScript A function is a block of code designed to perform a particular task. It is executed when it is invoked (called).A function in JavaScript is a reusable block of code that performs a specific task. It runs only when it is called (invoked). Avoid repeating code Organize programs Make code easier to understand and maintain Syntax of a Function `function functionName(parameters) { // code to be executed }`

example `function greet() { console.log("Hello, Welcome!"); } greet(); // Function call`

Function with Parameters function add(a, b) { return a + b; }

console.log(add(5, 3)); // Output: 8

1.What is a function in JavaScript? 2.Why do we use functions? Reduce code repetition Improve readability Organize code Make debugging easier 3.What are parameters and arguments? Parameters are variables listed in the function definition. Arguments are values passed to the function when calling it. Example: function show(name) { // name → parameter

4.What is the difference between return and console.log()? return sends a value back to the function caller. console.log() prints the output to the console. 5.What are the types of functions in JavaScript? Named Function Anonymous Function Arrow Function Function Expression Callback Function 2.Arrow Function in JavaScript An arrow function is a compact syntax for writing function expressions using the => (arrow) operator. An arrow function is a shorter and modern way to write a function in JavaScript. It was introduced in ES6 (ECMAScript 2015). Arrow functions make code cleaner and more readable. Syntax const functionName = (parameters) => { // code }; Normal Function function add(a, b) { return a + b; } console.log(add(5, 3));

Arrow Function const add = (a, b) => { return a + b; } console.log(add(5, 3));

1.Why were arrow functions introduced in JavaScript? Reduce code length Improve readability Handle the this keyword more effectively Make callback functions simpler 2.What are the main