NA +91-8727899942 thecoderjob@gmail.com

CHAPTER - 4

Clouser function in javascript || encapsulate the outer function variables.

In JavaScript, a closure is created when a function is defined inside another function, and the inner function has access to the variables of the outer function.

This allows the inner function to "close over" or encapsulate the outer function's variables.

Closures are a powerful and important concept in JavaScript, and they are commonly used to create private variables, handle asynchronous code, and more.

Here's is the Code !!

// Neel.B
const clouserFunction = () => {
	let data = "Hello Neel"
	return () => {
		return `${data} how r u?`
	}
}

const closureInit = clouserFunction()
const closureData = closureInit()
console.log(closureData)
//output : Hello Neel how r u?

Chapter 3

Get highest number in the array || javascript

Previous chapter

Chapter 5

What is IIFE function in javascript?

Next chapter

Get In Touch

NA

thecoderjob@gmail.com

+91-8727899942

Popular Links

© www.thecoderjob.com. All Rights Reserved.               Designed by HTML Codex