Teddy Day-Feb 10th- Callbacks with my Lover JS (JavaScript)
Today is the teddy day and as all of you know that yesterday was the chocolate day and my lover Js demanded 5 different box of chocolates from me and I too give her the present, although I didn't know why she demanded 5 chocolateBoxes from me as she can demand just 5 chocolates from me and this will save my money in boxes too. Oh! ok leave that , my frugal nature always speaks up. Coming back to the story, today I didn't wait for my lover js to ask for a gift , I woke up early morning and bought "a big teddy" from the market (yeah today I used my hoodie and went out, even there was a fog outside , the readers who had previously read the 7th Feb - Rose Day story , will knew the context, in case you missed out here is the link for you.) devkeycode.hashnode.dev/rose-day-feb-7th-co..
So, I gifted her the teddy and she was very happy and she smiled at me. Looking at smile, I knew a new demand is coming. And yes, I was right. She rquested me to get a new big box for her so that she can put all chocolateBoxes (that I bought for her yesterday on chocolateDay) in the big box.
But I asked her how she gonna kept all the boxes in a single box and answer I got as that she will use "Arrays".She just given the picture of the arrays and told me to show it to the shopkeeper , the shopkeeper will understand. So, finally I bought a bigBox for her from the market. And she taken all the chocolate boxes from yesterday and kept it inside a bigBox like this.
const bigTeddy = "bigTeddy";
const chocolateBox1 = "Ferrero Rocher Chocolate";
const chocolateBox2 = "Ferrero Rocher Chocolate";
const chocolateBox3 = "Ferrero Rocher Chocolate";
const chocolateBox4 = "Ferrero Rocher Chocolate";
const chocolateBox5 = "Ferrero Rocher Chocolate";
const bigBox = [ chocolateBox1,
chocolateBox2,
chocolateBox3,
chocolateBox4,
chocolateBox5
];
console.log(bigBox);
[ 'Ferrero Rocher Chocolate', 'Ferrero Rocher Chocolate', 'Ferrero Rocher Chocolate', 'Ferrero Rocher Chocolate', 'Ferrero Rocher Chocolate' ]
So after she put all the chocolateboxes inside the bigBox , she told me that today she had planned the day with her friends , so Don't disturb her! After listening her thought, I got sad. But I knew why she calling her friends as she sometimes like to showOff the new things she got with her and this time it was "a big teddy".But still i didn't get why she asked for bigBox from me, that has yet to be revealed. So, she called her friends - Java, Python, Go and Rust. Yeah, her friends also belong to programming family- Big Names!
And write the so much big code that i have to embed it here and she played a game with them.
Just click on run and wait for few seconds, you will get to know the output of the above code.
After all this, I knew why she asked a bigBox.Along with me, you also get to know about Arrays , callbacks and callback hell in JavaScript. And one more thing I want to add here is that you know what there are 2 types of callbacks are there - synchronous and asynchronous callbacks . Here the given code is an example of synchronous callbacks i.e they are of blocking nature. We will discuss asynchronous callbacks later. Stay tuned for more upcoming articles.
In case the below embeded code, doesn't displayed here is the link of the code.