DEV Community

ViGnEsH
ViGnEsH

Posted on

Return types, constrution function, Array methods

April 07 2026

FUNCTION

A function is a block of reusable code used to perform a specific task.

Why used function ?

The are used for specific task store one any the used for other code.

Syntax

function functionName {
// code
};
Enter fullscreen mode Exit fullscreen mode

Example

Types of function

  • Normal Function

  • Function Expression

  • Arrow Function


RETURN TYPES

The return keywords used to send a value back to funtion.

Syntax

function functionName {
// code
// return a+b;
};
Enter fullscreen mode Exit fullscreen mode

Example

Types of Return Values

Number > return 1, 2...
String > return "vignesh"
Boolean > return true or false
Array > return [1,2,"vig",4]
Object > return {name:"Vignesh"}


CONSTRUCTOR

A constrution is special fuction used to create new objects. this is blueprint.

Example

Key points

new keyword is used different store.
this keyword is used refers to current object.
Used is multiple object created.


Array Method

array store multiple object in single variables.

let numbers = [10, 20, 30];
Enter fullscreen mode Exit fullscreen mode

push() -> add element
push()
pop()
shift()
unshift()
forEach()
map()
filter()
reduce()
find()
findIndex()

(to be discuss )


Top comments (0)