JavaScript REST PARAMETERS in 8 minutes! 🗄

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

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

  • @BroCodez
    @BroCodez  11 месяцев назад +12

    // rest parameters = (...rest) allow a function work with a variable
    // number of arguments by bundling them into an array
    // spread = expands an array into separate elements
    // rest = bundles separate elements into an array
    // -------- EXAMPLE 1 --------
    function openFridge(...foods){
    console.log(...foods);
    }
    function getFood(...foods){
    return foods;
    }
    const food1 = "pizza";
    const food2 = "hamburger";
    const food3 = "hotdog";
    const food4 = "sushi";
    const food5 = "ramen";
    openFridge(food1, food2, food3, food4, food5);
    const foods = getFood(food1, food2, food3, food4, food5);
    // -------- EXAMPLE 2 --------
    function sum(...numbers){
    let result = 0;
    for(let number of numbers){
    result += number;
    }
    return result;
    }
    function getAverage(...numbers){
    let result = 0;
    for(let number of numbers){
    result += number;
    }
    return result / numbers.length;
    }
    const average = getAverage(75, 100, 85, 90, 50);
    console.log(average);
    // -------- EXAMPLE 3 --------
    function combineStrings(...strings){
    return strings.join(" ");
    }
    const fullName = combineStrings("Mr.", "Spongebob", "Squarepants", "III");
    console.log(fullName);

  • @danielmelek9348
    @danielmelek9348 10 месяцев назад +18

    If you are reading this and you know BroCode in person give him flowers He deserves it million times . Thank you bro.

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

    One day, I hope I can meet him in person and express my gratitude for helping me through the journey to become a web and software developer.

  • @szymonpiechutowski2340
    @szymonpiechutowski2340 11 месяцев назад +1

    Thank you for providing a high-quality edition for free! Love your content. Will you create Assembly series?

  • @MONSTROSITY
    @MONSTROSITY 2 месяца назад +2

    Congrats on 2 mil subs Bro!!

  • @yosef_animtion55
    @yosef_animtion55 10 месяцев назад +2

    Explain nodeJS to us

  • @piotrmazgaj
    @piotrmazgaj Месяц назад

    This is my seal. I have watched the entire video, understood it, and I can explain it in my own words, thus I have gained knowledge. This is my seal.

  • @harshjaiswal1634
    @harshjaiswal1634 9 месяцев назад

    combineString("Mr", "Bro", "Code");
    function combineString(...str){
    console.log(...str);
    can we do like this also?

  • @LeenaCruz
    @LeenaCruz 2 месяца назад

    Wow, thank you so much, you explain super clear!

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

    Thank you bro for providing this type of content, even if you don't have enough views, best of the best

  • @dressou23dressou23
    @dressou23dressou23 8 месяцев назад

    Thank you for providing us this high-quality content

  • @khalidelgazzar
    @khalidelgazzar 9 месяцев назад

    This is crazy! Very well explained. Thank you!

  • @capslock3250
    @capslock3250 29 дней назад

    When NodeJS?

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

    Hey Bro could you please upload react videos often please

  • @sf-zr3oj
    @sf-zr3oj 3 месяца назад

    you are great! Hi by Brazil

  • @emansem-e2s
    @emansem-e2s 3 месяца назад

    Thank you very much😃

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

    Django course pls

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

    Hello bro!Nice video!

  • @kubanek0958
    @kubanek0958 11 месяцев назад

    You are the best😀

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

    heyy..!!! Bro Code..!! Thanks for this amazing PHP course...!!! But Now we want Laravel Complete course Zero to Hero..!! so please as soon as possible made a full video course on PHP laravel..!!

  • @nhatan2511
    @nhatan2511 4 месяца назад

    Thank you so much