// 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);
@nguyengiorno9026 Жыл бұрын
You should have more views
@mehrnoushghaffarzadeh49714 ай бұрын
Perfect explanation! Thank you!
@danielmelek9348 Жыл бұрын
If you are reading this and you know BroCode in person give him flowers He deserves it million times . Thank you bro.
@MONSTROSITY4 ай бұрын
Congrats on 2 mil subs Bro!!
@szymonpiechutowski2340 Жыл бұрын
Thank you for providing a high-quality edition for free! Love your content. Will you create Assembly series?
@dressou23dressou2310 ай бұрын
Thank you for providing us this high-quality content
@mahmad-um4ytАй бұрын
This man is a gem ❤❤
@yehor802 Жыл бұрын
Thank you bro for providing this type of content, even if you don't have enough views, best of the best
@khalidelgazzar10 ай бұрын
This is crazy! Very well explained. Thank you!
@piotrmazgaj3 ай бұрын
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.
@LeenaCruz4 ай бұрын
Wow, thank you so much, you explain super clear!
@kubanek0958 Жыл бұрын
You are the best😀
@abrahamgebremariam Жыл бұрын
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.
@emansem-e2s5 ай бұрын
Thank you very much😃
@sf-zr3oj5 ай бұрын
you are great! Hi by Brazil
@Xyron_Official Жыл бұрын
Hello bro!Nice video!
@capslock32502 ай бұрын
When NodeJS?
@harshjaiswal163411 ай бұрын
combineString("Mr", "Bro", "Code"); function combineString(...str){ console.log(...str); can we do like this also?
@Blitz61wasd Жыл бұрын
Django course pls
@shreehari2589 Жыл бұрын
Hey Bro could you please upload react videos often please
@yosef_animtion55 Жыл бұрын
Explain nodeJS to us
@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..!!