Похожие чаты

Hi, I can't understand promises in JavaScript and what we

should use them for (maybe the teacher didn't teach well XD). Do you have a solution for this? And are promises used a lot in node.js and are important ?

29 ответов

9 просмотров

Promises make sense after you trip over callbacks. If you don't use callbacks in your code (meaning you don't do asynchronous stuff like read from filesystem or fetch resources over the network) then promises aren't really useful

Yeah learning promises is pretty much a MUST Also don't be hard on yourself since it might be the first time you've heard about this concept (the event loop and how it executes code etc...) Keep learning from different resources and practice it, that's how I understood it

A- Автор вопроса
Ibrahim Ngeno
Promises make sense after you trip over callbacks....

It's mean promises aren't use lot in node.js ?

A- Автор вопроса
Senator
Yeah learning promises is pretty much a MUST Also ...

Yes, this is the first time I worked with it and it was hard for me to understand where it is used and what it is used for. Do you know a video or a special resource for learning promises that is good and easy?

A
It's mean promises aren't use lot in node.js ?

They are, but they aren't a must just yet. But you should learn them, they make life sooo much easier

A- Автор вопроса
Ibrahim Ngeno
They are, but they aren't a must just yet. But yo...

Oh thanks you :) can you suggest me a video for that ?

A
It's mean promises aren't use lot in node.js ?

For just about every asynchronous task, you can use callbacks. But expect that to change as more stiff becomes promise based

A
Oh thanks you :) can you suggest me a video for th...

Hmmm ... Let me rummage through my browser history, there's probably something there. I'm mostly a text person so most of my links are to reference materials like MDN and books

A- Автор вопроса
Ibrahim Ngeno
For just about every asynchronous task, you can us...

Maybe it will be difficult for me at first and I will be able to learn it over time

A
Maybe it will be difficult for me at first and I w...

Yeah, it was that way for most of us. Promises were developed to solve a class of problems not everyone faces and especially not in the beginning

A
Maybe it will be difficult for me at first and I w...

Have you any experience using JS for web development? Have you done anything in node?

A- Автор вопроса
Ibrahim Ngeno
Hmmm ... Let me rummage through my browser history...

Oh, I would be grateful if you could give me a tutorial in simple language. And of course, I'm sorry for bothering you 🙏

A
Oh thanks you :) can you suggest me a video for th...

I remember this video helping me grasp the concept, but it was a long time ago and I'd been beating my head about it for a while https://youtu.be/2d7s3spWAzo

A- Автор вопроса
Ibrahim Ngeno
Have you any experience using JS for web developme...

No, I'm currently learning JavaScript after that i will start node

A
No, I'm currently learning JavaScript after that i...

This is a basic guide I used multiple times whenever I needed to remind myself https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises

A- Автор вопроса
Ibrahim Ngeno
I remember this video helping me grasp the concept...

Thank you very much, maybe this video can definitely help me ❤️❤️❤️

A
Thank you very much, maybe this video can definite...

Maybe, and if not see what YouTube recommends after watching that

A- Автор вопроса
A
I will definitely read it. Thank you :))))

I also like w3schools when I want a quick tutorial (for more in depth, find a nice big boring book) https://www.w3schools.com/js/

A- Автор вопроса
Ibrahim Ngeno
I also like w3schools when I want a quick tutorial...

Yes, w3school will probably help me, but the video you sent me made me happy the most, and I thank you again for your guidance 🙏❤️

A- Автор вопроса

Learn callbacks first. Promises are just a solution for the callback hell problem. Also known as the callback pyramid or pyramud of doom

They are used a lot. Also async/await (another way of handling async code) are used a lot. Makes the code cleaner

It's okay you will be better in future if you work with that

StringManolo
Learn callbacks first. Promises are just a soluti...

Hummm , What is the best video tutorial for callbacks?

Ha$H
Hummm , What is the best video tutorial for callba...

No idea. I almost don't watch videos. I can explain it to you. The a callback function is a regular function that is passed as argument to other function. For example: const sayName = function ( name, do_something_with_name) { console.log( do_something_with_name(name) ); } const toUpperCase = name => name.toUpperCase(); const reverse = name => name.split('').reverse().join(''); sayName("manolo", toUpperCase); sayName("manolo", reverse); This pattern is very usefull to work with asyncronous code. For example to request multiple webpages at the same time . So you can make sure that your callback function is called after the data is fetched from the remote server. For example, is used a lot with fetch function.

A
Yes, this is the first time I worked with it and i...

Unfortunately it's been a long time since I've visited those resources, but just search through YouTube and watch a few of them and practice the code they're writing, you'll get the hang of it pretty fast

A- Автор вопроса
StringManolo
They are used a lot. Also async/await (another w...

Thanks you for help I'm so glad for this JavaScript community and thanks you for helping me ❤️

Похожие вопросы

Обсуждают сегодня

А чем вам питонисты не угодили?😂
.
79
So total 101m burned Today?
Simu
18
Всем привет, написал код ниже, но он выдает сегфолт, в чем причина? #include <stdio.h> #include <stdlib.h> #include <string.h> struct product { char *name; float price; };...
buzz базз
75
всем доброго времени суток! имею вопрос: как понять ТОЧНО, что на нексус производится атака или он перегружен? исходные данные: - Nexus OSS 3.67.1-01 на OrientDB - Total co...
Michael Kostelcev
11
Ребят, а за скок можно впарить анон чат с апишкой и веб админкой ?
Eugene Неелов
15
GM, Oceaners! 🌊 Phase 1 of the ASI token merger begins today at 15:00 UTC! We've been prepping you for this 💪 Remember: 1. DO NOT RUSH! Plenty of time for this merge; Phase ...
Danil | Never DM first Kovtoniuk
8
So much happening but nothing happening? Why no proper progress towards mainnet? Why more and more people calling cartesi coin - sh** coin?
Abra Mov
9
or any website to buy prepaid card with xmr that's not trocador that's down?
Umbrella Party Partner
18
Basically these people say: "We took a decision, shutup and accept that!" Don't matter how it will hurt people that believed in the project, they simply don't care. It give ...
Felipe Rocha
3
does anyone know if BitMart is automatically swapping OCEAN for ASI for the merger ? I did not receive any info about the trading/withdraw suspensions and have these coins st...
Lucy Marie
7
Карта сайта