About

Sunday, 7 November 2021

Callback hell in Javascript

 const RollNo = () => {

    setTimeout(() => {
        console.log('Api getting to roll out');
        let roll = [1,2,3,4,6];
        console.log(roll);

        setTimeout( (roll) => {
            const biodata = {
                name : "vinod",
                age : 23
            }
            console.log(`My roll no is ${roll}. My name is ${biodata.name} and my age is ${biodata.age}`);

            setTimeout( () => {
                biodata.gender = "male"
                console.log(`My gender is ${biodata.gender}. My name is ${biodata.name}. While my age is ${biodata.age}. My roll no is ${roll}`);
            }, 2000);

        }, 2000, roll[1]);

    }, 2000);

}
RollNo();