JavaScript REST PARAMETERS in 8 minutes! 🗄

Поділитися
Вставка
  • Опубліковано 15 лис 2024

КОМЕНТАРІ • 24

  • @BroCodez
    @BroCodez  Рік тому +13

    // 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 Рік тому +22

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

  • @dressou23dressou23
    @dressou23dressou23 10 місяців тому

    Thank you for providing us this high-quality content

  • @szymonpiechutowski2340
    @szymonpiechutowski2340 Рік тому +1

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

  • @mahmad-um4yt
    @mahmad-um4yt Місяць тому

    This man is a gem ❤❤

  • @khalidelgazzar
    @khalidelgazzar 10 місяців тому

    This is crazy! Very well explained. Thank you!

  • @MONSTROSITY
    @MONSTROSITY 3 місяці тому +4

    Congrats on 2 mil subs Bro!!

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

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

  • @LeenaCruz
    @LeenaCruz 4 місяці тому

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

  • @piotrmazgaj
    @piotrmazgaj 3 місяці тому

    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.

  • @emansem-e2s
    @emansem-e2s 4 місяці тому

    Thank you very much😃

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

    You are the best😀

  • @sf-zr3oj
    @sf-zr3oj 5 місяців тому

    you are great! Hi by Brazil

  • @abrahamgebremariam
    @abrahamgebremariam Рік тому +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.

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

    Hello bro!Nice video!

  • @harshjaiswal1634
    @harshjaiswal1634 11 місяців тому

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

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

    Django course pls

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

    Hey Bro could you please upload react videos often please

  • @capslock3250
    @capslock3250 2 місяці тому

    When NodeJS?

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

    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..!!

  • @yosef_animtion55
    @yosef_animtion55 Рік тому +2

    Explain nodeJS to us

  • @nhatan2511
    @nhatan2511 5 місяців тому

    Thank you so much