For JavaScript
This type of functions are called anonymous functions, meaning they don’t need a function name
Here we said that Function expressions are anonymous(nameless function)
But you can still give function name, it will help during the debuggin process
This works too
But you can still give function name, it will help during the debuggin process
const func = function sayHi() {
//code
}
This works too
Arrow Functions
My Favourite
Arrow function is shorter syntax of function expressions
They are always expression, not declaration, meaing they are not hoisted either
In arrow functions
Or also, if we want to return an object, we can wrap it up inside ( ) to implicitly return it (with => )
My Favourite
Arrow function is shorter syntax of function expressions
They are always expression, not declaration, meaing they are not hoisted either
const sum = (a, b) => a + b
In arrow functions
=> means return, so it uses implicit return. That means, after => the keyword return is not required. But if you add curly braces { } after =>, then you need to explicitly return the value
const sum = (a, b) => {return a + b}
Or also, if we want to return an object, we can wrap it up inside ( ) to implicitly return it (with => )
const sum = (age, gender) => ({age, gender})
Promise?
Promise in JS is an object that represents an eventual completion of an async operation.
To put it simply, we can say it’s a literal ‘promise’ that there will be a result of your request(be it successful, or rejection)
It’s like saying:
Promise has 3 states: Pending, Fulfilled, Rejected
How does it relate to async/await?
In the next post) soon
Promise in JS is an object that represents an eventual completion of an async operation.
To put it simply, we can say it’s a literal ‘promise’ that there will be a result of your request(be it successful, or rejection)
It’s like saying:
I don’t have the data now, but I Promise, I will give it to you
Promise has 3 states: Pending, Fulfilled, Rejected
How does it relate to async/await?
In the next post) soon
❤1
Tired of ‘.then’s???
Here’s a easier, and readable syntax
So, generaly async and await makes Promises easier to write
—
—
fetchData()
.then(res => res.json())
.then(data => console.log(data))
.catch(err => console.error(err));
Here’s a easier, and readable syntax
async function getData() {
try {
const response = await fetch(“blah blah com”);
const data = await response.json();
console.log(data);
} catch (error) {
console.error("Error:", error);
}
}
So, generaly async and await makes Promises easier to write
—
async keyword is making it asynchronous operation—
await keyword is pausing the code untill the response comes from PromisesClosure
Closure is when an inner function remembers the variable from an outer(parent) function
How is it different from scope?
- In scope, once the parent function is done, the variables declared there will also be gone. No memory of variables stays.
Sooo, but in closure, the inner function can still remember the variable
- Closures work only if parent function is returned, or passed somewhere
Closure is when an inner function remembers the variable from an outer(parent) function
How is it different from scope?
- In scope, once the parent function is done, the variables declared there will also be gone. No memory of variables stays.
Sooo, but in closure, the inner function can still remember the variable
- Closures work only if parent function is returned, or passed somewhere
Cloning?
1) Shallow Cloning - is used when object is plain and simple data, not like nested-type.
So, here we can see that cloning an object and changing one key property have not changed the original one.
When we shallow clone, we create a new object with different memory locations. and it will create new locations for only primitive data types in the object(like strings, numbers…). If the object includes nested objects, then it will copy only the reference to that memory.
Cloning is usefull when we want to keep the original object safe and create a copy to modify. So, our modifications will only affect our new cloned object. There are two ways of cloning
1) Shallow Cloning - is used when object is plain and simple data, not like nested-type.
let original = {name: “Javohir”, age: 22}
let shallow = {…original}
shallow.name = “Behruz”
console.log(original.name)
//Output: Javohir
So, here we can see that cloning an object and changing one key property have not changed the original one.
When we shallow clone, we create a new object with different memory locations. and it will create new locations for only primitive data types in the object(like strings, numbers…). If the object includes nested objects, then it will copy only the reference to that memory.
btw, I am back to JS🔥
Kelayotgan midterm o’z yo’liga😅,
Anyways, 2 kunda genius bo’lib ketib, midtermni 100ga topshirolmayman
Kelayotgan midterm o’z yo’liga😅,
Anyways, 2 kunda genius bo’lib ketib, midtermni 100ga topshirolmayman
Please open Telegram to view this post
VIEW IN TELEGRAM
🤯1
2) Deep Cloning — is used when object includes nested data, non-primitive type, like object, or arrays
Deep Cloning creates a totally independent new object in new memory location, even if object has nested object inside.
In the exampe, it can be seen that nested object’s value hasn’t changed even after different value has been assigned to it with cloning. If it were shallow cloning, original value would have been modified.
let original = {name: “Javohir”, info: {year: 2003}}
let deepClone = structuredClone(original)
deepClone.info.year = 2002
console.log(original.info.year)
//Output: 2003
Deep Cloning creates a totally independent new object in new memory location, even if object has nested object inside.
In the exampe, it can be seen that nested object’s value hasn’t changed even after different value has been assigned to it with cloning. If it were shallow cloning, original value would have been modified.
Bugun birinchi marta NodeJS orqali authentication qurib bitkazdim
Va frontendga ulab UI orqali sinab ham ko'rdim. And It worked!🔥
Va frontendga ulab UI orqali sinab ham ko'rdim. And It worked!
Please open Telegram to view this post
VIEW IN TELEGRAM
Code Insights🎗
😭😭 Aynan menga kerak paytida ham shu github ni dardi qo’zib qoladimiyaa
Butun boshli gitni push/pull systemi pishibti ekan,
ehh kutamiz🥲
O’zi bir kechasida ishlashga ilhom keluvdi, shuniyam beliga tepishdi, heh
Hullas, Github CEO siga aytib qo’yina, ertalabgacha to’g’rilab qo’ysin 😅, ertaga yangi loyihani taqdimoti boree
ehh kutamiz
O’zi bir kechasida ishlashga ilhom keluvdi, shuniyam beliga tepishdi, heh
Hullas, Github CEO siga aytib qo’yina, ertalabgacha to’g’rilab qo’ysin 😅, ertaga yangi loyihani taqdimoti boree
Please open Telegram to view this post
VIEW IN TELEGRAM
😁4
Hehe, bu yaramasni qarayna
kecha 2 soat bitta task qilolmadi. Murakkablashtirib tashladi. Keyin taskni yopdimda, bugun kelib o’zim 10 minut try qilib topib qo’ydim. ChatGPT esa endi paxta qo’yib yotibti
Thanos-snap…mush
Bu kecha bergan yechimlarini ko’rib, shunaqa qiyinmikin buni to’g’rilash deb turuvdim, bilsam oddiy conditional rendering kerak bo’lgan ekan😅
1 qator bilan fix bo’lib ketdi
kecha 2 soat bitta task qilolmadi. Murakkablashtirib tashladi. Keyin taskni yopdimda, bugun kelib o’zim 10 minut try qilib topib qo’ydim. ChatGPT esa endi paxta qo’yib yotibti
Thanos-snap…mush
Bu kecha bergan yechimlarini ko’rib, shunaqa qiyinmikin buni to’g’rilash deb turuvdim, bilsam oddiy conditional rendering kerak bo’lgan ekan😅
1 qator bilan fix bo’lib ketdi
🤣6😁3🔥2
Forwarded from GDG Tashkent (Asilbek 🐢)
ALMOST 2 DAYS. Panorama Cinema Palace📍
Already counting down the hours?
This Saturday, the entire GDG community will descend upon one of the city's most famous landmarks.
Imagine the energy of hundreds of devs in one massive hall. The vibe is going to be unmatched, and the location is legendary.
#devfest2025
📅 December 6
🎟 Get your FREE ticket now: link
📋 Agenda: https://bit.ly/DevFest-agenda-2025
Telegram | Instagram | LinkedIn
Already counting down the hours?
This Saturday, the entire GDG community will descend upon one of the city's most famous landmarks.
Imagine the energy of hundreds of devs in one massive hall. The vibe is going to be unmatched, and the location is legendary.
#devfest2025
📅 December 6
🎟 Get your FREE ticket now: link
📋 Agenda: https://bit.ly/DevFest-agenda-2025
Telegram | Instagram | LinkedIn
❤🔥2👍1🔥1
AI ni yugurgani somonxonagacha…)
E’tibor bersam, hech bu yerda AI ni maqtab emas, balki doim nimadir ishimni qilolmasa yozarkanman😅
E’tibor bersam, hech bu yerda AI ni maqtab emas, balki doim nimadir ishimni qilolmasa yozarkanman😅
💯2😁1🗿1
Code Insights🎗
AI ni yugurgani somonxonagacha…) E’tibor bersam, hech bu yerda AI ni maqtab emas, balki doim nimadir ishimni qilolmasa yozarkanman😅
Ishlagan paytlari ishni tez-tez qildirib ketavermizda
Ishlamay qolsa keyin asabimizni buzib turaverganda, shunaqa ilhom parisi keladi yozishga😅
Ishlamay qolsa keyin asabimizni buzib turaverganda, shunaqa ilhom parisi keladi yozishga😅
👍1🔥1😁1
Real-case:
Refactor qilish uchun 300 qator kod bergan edim. Qilishga ham qildi, yaxshiyam chiqdi, ishladi, merge qilib deploy ham qildik.
1 xafta o’tdi. Endi qing’ir ishining tagi ko’rinib qoldi. Yaramas, refactor qilayotganda bir asosiy qismini tashlab ketgan ekan. 😭
😱2🤣2🤬1
Commentda Final exam deyilganiga esimga tushib ketdi:
Men bugungi Circuit and Lab fanidan imtixonda javoblar varoqasiga eng ishonchim komil bo’lib yozgan narsam bu meni ism familyam bo’ldi🤣7👏1🏆1
Forwarded from Insights || Blog🎗 (Javohir Mirzakhalov)
SATashkent is hiring
We are looking for
✅ Frontend Developers✅ Backend Developers✅ AI Engineers
for internship or junior positions.
No prior experience is required. Are you the right person or do you know someone who might be? refer to us
For more information and referral write to @mirzakhalov03
@JM_personalblog
Please open Telegram to view this post
VIEW IN TELEGRAM
👍2