16.12: Promises Part 2 - Topics of JavaScript/ES6

Поделиться
HTML-код
  • Опубликовано: 4 ноя 2024

Комментарии •

  • @Nonsense116
    @Nonsense116 5 лет назад +43

    I love learning from you so much. The biggest bummer to learning things about programming is people tend to over complicate things when they don't need to. I guess to sound super smart??? Every time I watch a video from you nothing is over complicated. It's stated just how it is. THANK YOU! Also thank you for teaching me about promises.

    • @CameronChardukian
      @CameronChardukian 5 лет назад

      I agree with you 100% Grant.

    • @victorgasparoni
      @victorgasparoni 4 года назад +3

      The bad thing about most developers is that they are the ultimate flexers.

    • @_unknown7_
      @_unknown7_ 2 года назад

      @@victorgasparoni 😐

  • @epictetus-nicopolis
    @epictetus-nicopolis 2 года назад +1

    I just come back and re-watch these videos, just to feel your positive energy. Thank you 😍

  • @zee1598
    @zee1598 3 года назад +12

    Can I just say, I love your energy, you're making this learning process really fun.

  • @MicheleMasina
    @MicheleMasina 6 лет назад +40

    Hey Dan, just another quick tip to make your code slightly shorter. When you write .catch(err => console.error(err)) you can just write .catch(console.error) instead. This is the case every time you would call an arrow function with just one parameter, only to call another function on that parameter.

    • @saurabh75prakash
      @saurabh75prakash 5 лет назад +3

      @Sph2329 do we need bind() here, I think the arrow syntax (even though not explicitly present) will take care of the context, so we need not fix "this" using bind IMHO.

  • @erfanrj2780
    @erfanrj2780 2 года назад +1

    I love your channel ! it's about 2 days that I found it. since I watched your first video about js, I search topics that I'm looking for, first.

  • @FaithFedora
    @FaithFedora 10 месяцев назад

    I have never been so excited to learn programming 😊😊😊

  • @predicate
    @predicate 6 лет назад +140

    can someone please make a 10 hour version of 5:45?

    • @TheCodingTrain
      @TheCodingTrain  6 лет назад +42

      I fully endorse this project idea.

    • @bbit-solutions7004
      @bbit-solutions7004 6 лет назад +13

      gph.is/2P7lNDP

    • @beccaarauz
      @beccaarauz 6 лет назад +5

      HAHAHAHAHA OMG NO, I almost had an anxiety attack with this

    • @CameronChardukian
      @CameronChardukian 5 лет назад

      Haha that was a struggle

    • @ark333
      @ark333 4 года назад

      @@bbit-solutions7004 this doesn't work

  • @dongyoungkim962
    @dongyoungkim962 2 года назад

    amazing explanation that takes time to actually how each component works in depth.

  • @rampage9530
    @rampage9530 4 года назад +1

    Simply... you are an excellent teacher !

  • @TheBarthinator
    @TheBarthinator 6 лет назад +9

    oh my this is way easier than i thought

  • @martinsonuoha
    @martinsonuoha 6 лет назад +14

    Your tutorials are awesome!

  • @martutittu
    @martutittu 3 года назад

    When you walk between frames it reminds me so freakin' much of logi mouse moving between screens :). Great tut, thank you !

  • @ouza1430
    @ouza1430 6 лет назад +1

    you are a gifted professor

  • @11am
    @11am 5 лет назад

    i just love the way you teach, it is just so engaging! thank you so much!

  • @nnrmnlg
    @nnrmnlg 6 лет назад +16

    Could you do some more native javascript? I feel like it would be interesting

  • @t100210022002
    @t100210022002 4 года назад

    You really are a great teacher.

  • @tbntdima
    @tbntdima 6 лет назад +1

    I was reading eloquent js for 4 days, and couldn't get this topic.
    Thanks for video!

  • @Gottii92
    @Gottii92 6 лет назад +46

    who's watching this in the year 3122?
    11:11

  • @navdeepbhanderi
    @navdeepbhanderi 2 года назад

    Great teacher on the earth 🌎.

  • @amanhaman8568
    @amanhaman8568 6 лет назад +1

    despite knowing most of the stuff, it:s entertaining to watch. nice!

  • @robocop30301
    @robocop30301 6 лет назад +1

    Very informative, and also entertaining. Thank you!!

  • @Cloud-577
    @Cloud-577 4 года назад

    My fav channel!!

  • @idontevenknow3707
    @idontevenknow3707 6 лет назад +2

    Hi DAN! not supposed to be here, still on the p5js tutorials, I SHALL CATCH UP THOUGH! Peace & Love on the CodingTrain! CHOoOOOoOoooOOOoOCHooOOOoOOO

  • @Caraxian
    @Caraxian 6 лет назад

    I know all this but you make it so interesting to watch so I like to watch anyway :D

    • @Caraxian
      @Caraxian 6 лет назад

      Can’t wait for async/await since I’m not quite familiar with them

  • @kebman
    @kebman 6 лет назад

    *fetch()* still isn't built into Node.js, so in the mean time you need to do *npm install node-fetch --save*

  • @jxs489
    @jxs489 7 месяцев назад

    Great video! Thank you so much

  • @shifter65
    @shifter65 3 года назад

    Really like your ES6 explanations. Any plans to do more?

  • @어깡갱
    @어깡갱 6 лет назад

    Daniel you're Genius!!

  • @davidyankee1986
    @davidyankee1986 6 лет назад

    Thanks Daniel... very Useful do you have any video or plan of video where we get data from firebase using a searchbox?

  • @RSTao77432
    @RSTao77432 5 лет назад

    Hi, you have a SetUp Function() then you have a NoCanvas Function.. Jusst curious! Does Javascript automatically create a canvas in the DOM? & if so/ or not... is NoCanvas a native JS function itself? or have you defined that elsewhere? Promises looking handy.

  • @jorgelightwave
    @jorgelightwave 5 лет назад +1

    I'm learning a lot with your videos!
    PS: ES stands for EcmaScript

  • @JBahrsShiz
    @JBahrsShiz 5 лет назад +1

    Noob question: at 3:41 you have delay() called on line 3, but defined on line 7. How does this work? I thought you had to define before calling. I could be mixed up too as I have limited experience. Got the code bug and trying to learn.

    • @IbnuCuruk
      @IbnuCuruk 5 лет назад +2

      Jason Bahr
      Functions that are written like that are hoisted; it means that the program can run it, even though they are written somewhere else of where they are called. Every function notations have their pros and cons.
      Please correct me if I’m wrong. I’m still a noob too.

  • @clevermissfox
    @clevermissfox 10 месяцев назад +1

    How are the functions noCanvas() and createP() working ? Where are they defined ?

    • @TheCodingTrain
      @TheCodingTrain  10 месяцев назад +1

      These are part of the p5.js library! p5js.org/

    • @clevermissfox
      @clevermissfox 10 месяцев назад +1

      @@TheCodingTrain only first heard of p5 on your channel. Will check into it!

  • @user-zp1dv4yh5e
    @user-zp1dv4yh5e 4 года назад

    Did you created the pj5 library?

  • @Caraxian
    @Caraxian 6 лет назад +5

    You should really cancel execution of the function after rejecting otherwise the program will be running the setTimeout to resolve a rejected promise which is a waste of system resources :)

    • @Caraxian
      @Caraxian 6 лет назад +1

      Oh it’s fixed I’m the next video, which is unlisted :)

    • @TheCodingTrain
      @TheCodingTrain  6 лет назад +2

      yeah, i goofed!

    • @tempest_dawn
      @tempest_dawn 6 лет назад +1

      Good to hear it's fixed in the next one, but yeah it's really good to get in the habit of always returning if you reject or resolve a promise as I believe calling any of those functions more than once can result in undefined behavior?

    • @Caraxian
      @Caraxian 6 лет назад +2

      Cole Erickson depends on what it’s doing, but yea. The promise itself will be fine since it can only resolve or reject once but doing the action anyway could cause some problems elsewhere in some cases

  • @RakeshBitling
    @RakeshBitling 3 года назад

    You Videos are excellent please make javascript AWS developer S3 videos 👍👍👍👍

  • @Vibestr
    @Vibestr 2 года назад +1

    anyone notice that the output from the resolve never got delayed? I applied this code inside a console and it delayed it by the time indicated, but the createP method displayed the message right away.
    edit: i figured out my issue. The setTmeout() has to have a callback argument as follows and then the delay works:
    if (isNaN(time))
    reject(new Error(time + " is not a valid number"));
    else
    setTimeout(() => resolve("test resolved"), time);

  • @nomangulkhan
    @nomangulkhan 6 лет назад +4

    *You're Just amazing!!!!!!*

  • @etymology_
    @etymology_ 6 лет назад +1

    I may have missed this..but what is the createP..his HTML id? or is that a js method that appends the return data?

    • @TheCodingTrain
      @TheCodingTrain  6 лет назад +1

      It's part of the p5.js library, see: p5js.org.

  • @siluverukirankumar9954
    @siluverukirankumar9954 6 лет назад

    Is delay, resolve and reject are JavaScript built in keywords?

  • @maheenkhurram
    @maheenkhurram 5 лет назад

    Thank you very much really nice video. made simple and jokes are timely and interesting.

  • @IsfhanAhmed
    @IsfhanAhmed 6 лет назад

    can you make video on javascript and ecmascript without p5.js

  • @marlon4008
    @marlon4008 5 лет назад +1

    where does that resolve and the reject come from? is it a promise method?

    • @attilatoth268
      @attilatoth268 5 лет назад

      No. It's just a callback passed to the Promise constructor. The name resolve and reject is just a convention, but you can name it anything, it doesn't really matter.

  • @andromilk2634
    @andromilk2634 Год назад

    What I don't get is that when setTimeOut calls resolve, what does resolve do exactly? Is it a function which does nothing? Thanks

  • @notarealhandle123
    @notarealhandle123 5 лет назад

    Promises are made to be broken. Does it work here as well?

  • @grownmancrying
    @grownmancrying 5 лет назад

    My coworker told me you look like Hugh Jackman. Anyway thanks for the video man, love from PH.

  • @JBahrsShiz
    @JBahrsShiz 5 лет назад

    Thank you!

  • @jayakrishnalakkoju453
    @jayakrishnalakkoju453 4 года назад

    Let CodingTrain = () => setTimeout(()=>♥️, 1000);
    CodingTrain();

  • @juschu85
    @juschu85 6 лет назад +2

    8:40 Yes, it works. But why.
    You didn't put an else block around setTimeout and you don't return after you call reject. So even if the isNaN function returns true it should still execute setTimeout.
    Does that mean the function which is passed to the Promise constructor automatically returns after the function passed in the second argument is called?
    If yes, I don't like that. That should be in the control of the developer.

    • @kebman
      @kebman 6 лет назад

      No. Pretty sure you have to manually return it, as it's also a matter of security.

    • @juschu85
      @juschu85 6 лет назад

      kebman I didn't watched it all over again, but I think later (in another video(?)) he also noticed that he made a mistake at this point.

    • @nomtijorti
      @nomtijorti 5 лет назад

      no it won't. by default what comes after and if it considered else.

    • @attilatoth268
      @attilatoth268 5 лет назад

      It works because promises don't change after they settled (either fulfilled or rejected). So you cannot have a promise that will reject after 1 second, but then resolve after 2 second.
      In this implementation the setTimeout still happens, the resolve function will be called (after the delay), but it won't change the rejected promise into a fulfilled one.

  • @anmaraziz8360
    @anmaraziz8360 3 года назад

    your just amazing please keep doing things just the way u r funny & simple

  • @romanemul1
    @romanemul1 6 лет назад

    looks like we are heading times where java will be updating each few hours.

  • @amirulidzham3686
    @amirulidzham3686 5 лет назад

    Hello, why I need to use resolve() in my code. If not, then will never execute. I'm not sure it is related to angular. I have new Promise(resolve,reject). I expected that it will continue to execute and auto return resolve and if any error will return rejected

  • @jpc501
    @jpc501 6 лет назад

    Superb

  • @GeeVaaz
    @GeeVaaz 5 лет назад +1

    10:35 - YMCA

  • @ericvaldez174
    @ericvaldez174 5 лет назад

    Do you still write program people of year 3122?

  • @santiagojaramillorodriguez8272
    @santiagojaramillorodriguez8272 3 года назад

    how can I see my code in the browser? :(

  • @Nampjg
    @Nampjg 4 года назад

    using the Promise(resolve,reject) was almost felt to me like cheating in examination or plagiarism :(

  • @TheSaintsVEVO
    @TheSaintsVEVO 4 года назад

    2:00 aww 😂

  • @Ineffable_Wisdom
    @Ineffable_Wisdom 6 лет назад

    Can anybody tell me what the noCanvas() function is for?

  • @mkifd
    @mkifd 4 года назад

    Just came back from the year 3122 just to keep my promise 🤧

  • @alizahid4742
    @alizahid4742 6 лет назад

    where the react tutorials at. thank you

  • @jamoliddinz
    @jamoliddinz 3 года назад

    it's still relative)

  • @akinbolaoluwaferanmi898
    @akinbolaoluwaferanmi898 5 лет назад

    Hello, guys am a little bit confused tried running similar code in vanilla javascript while it works, the timing is completely off. the function runs immediately in the browser.
    delay(9000)
    .then(document.write('Promise is sucessful'))
    .catch(err => console.error(err))
    function delay(time){
    return new Promise((resolve,reject)=>{
    setTimeout(resolve,time);
    });
    }

    • @shonendumm
      @shonendumm 2 года назад

      Hi I encountered a similar issue, my resolve was returned immediately without delay. Then I read that it's because I wrote it as setTimeout(resolve(), time) . Note the parentheses. It should be setTimeout(resolve, time) .
      But I see that yours is written without parentheses, so it should run with delay though. That's strange.

  • @martinbozinovski
    @martinbozinovski 5 лет назад

    I am the only one that is trying codes? @7:15 the code doesnt work, at least not for me. Where am i taking a mistake? Here is the code, maybe can someone tell me with just a look at it:
    function setup() {
    delay(1000)
    .then(() => createP('Hello'))
    .catch((err) => console.error(err));
    }
    function delay(time) {
    return new Promise((resolve, reject) => {
    setTimeout(resolve, time);
    });
    }

  • @TutocarloCV
    @TutocarloCV 6 лет назад

    nice

  • @shineten4961
    @shineten4961 6 лет назад

    what is p5?

    • @TheCodingTrain
      @TheCodingTrain  6 лет назад

      p5 is a library for JavaScript, for more: p5js.org.

  • @ayush.kumar.13907
    @ayush.kumar.13907 6 лет назад

    The Anchor looks like Gilfoyle from Silicon Valley, LOL

  • @chizll
    @chizll 3 года назад

    Hi to all those watching in the year 3122! Sincerely, 2021

  • @kebman
    @kebman 6 лет назад

    What was I talking-saying?

  • @ramnathtejachekka7090
    @ramnathtejachekka7090 3 года назад

    who is watching this at 3422! ... all the people during lockdown be like "well it felt like millennium, so me!" :D

  • @ghazni101
    @ghazni101 3 года назад

    came for self help...going with self doubt

  • @Pareshbpatel
    @Pareshbpatel 2 года назад

    {2021-12-16}

  • @2e3crescens
    @2e3crescens 6 лет назад

  • @codegate615
    @codegate615 4 года назад

    This is over-complicated. Use easier examples to teach brand new and difficult material.

  • @nomangulkhan
    @nomangulkhan 6 лет назад +1

    How do you know that you have made any type of coding mistake? plz answer i am waiting!

    • @anibal9812
      @anibal9812 6 лет назад +2

      You test your program to see if it behaves the way you expect it to or if any error messages pop up. There’s a paradigm called Test-Driven Development (or TDD) that helps to automate this kind of thing, but I wouldn’t recomento to a complete beginner to programming, as it requires using libraries and writing even more code. If you’re comfortable with these things, however, check it out, it’s an awesome way to program.
      In JavaScript specifically, you check how the page answers to your inputs, and if there’s any red messages in the console.

    • @nomangulkhan
      @nomangulkhan 6 лет назад +2

      Thanks

    • @TheBarthinator
      @TheBarthinator 6 лет назад +2

      You could lookup a linter plug-in for atom

    • @nomangulkhan
      @nomangulkhan 6 лет назад +2

      Thanks BROTHER!

  • @praneetmehta
    @praneetmehta 5 лет назад

    Great video but your laugh is weird :P