#49 What are Pure Functions? | JavaScript Full Tutorial

Поділитися
Вставка
  • Опубліковано 16 січ 2025

КОМЕНТАРІ • 13

  • @SvetaSveta-ms4hi
    @SvetaSveta-ms4hi 3 роки тому +4

    It gets me so pumped up every time I recieve a notification from your channel. I thoroughly enjoy your tutorials. I'm in love with the way you explain complex stuff. You're so gifted 😍 You definitely have a knack for it.

    • @DevDreamer
      @DevDreamer  3 роки тому +1

      Thank you so much! You’re comments are fast becoming amongst my favourites! 😃👍 Are there any other tutorials you’d like to see on the channel?

    • @restingbitchface7101
      @restingbitchface7101 Рік тому

      YES! like Angular, React and Node.js@@DevDreamer

  • @jeremygl1569
    @jeremygl1569 День тому

    Im studying computer science right now and the explanation they gave us i think is easier to understand that what youre trying to explain.
    Impure functions are functions that do more than only what they state in their name f.e.
    let half = 0;
    function sum(a, b) {
    half = (a+b) /2
    return a+b;
    }
    As you can see, this 'sum' function is making an addition AND calculating/doing something else that has nothing to do with the name of the function 'sum'.
    To make it pure, you need to split the calculation into seperate functions; such as
    let half = 0;
    function sum(a, b) {
    divideBy2(a, b);
    return a+b;
    }
    function divideBy2(a, b) {
    half = (a+b)/2;
    }
    or even cleaner, but now you also change the structure so this might not be what you want since a and b dont need to be equal for both functions
    function sum(a, b) {
    return a + b;
    }
    function divideBy2(a, b) {
    return (a + b) / 2;
    }
    let result = sum(4, 6); // 10
    let half = divideBy2(4, 6); // 5

  • @slowANDsteady161
    @slowANDsteady161 Рік тому

    Thank you for making it this clear.A real great video👏

  • @jsjs2340
    @jsjs2340 3 роки тому +4

    comment for support

  • @designsxnellgraphics8667
    @designsxnellgraphics8667 2 роки тому

    Wonderful video sir. Thanks a lot

  • @appustudio8637
    @appustudio8637 3 роки тому +1

    👍👍👍 cool

  • @skadara9555
    @skadara9555 3 роки тому +1

    Very nice 😊

  • @LeonIAm
    @LeonIAm 2 роки тому +1

    could you create react js step by step tutorials like this? :)