Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Spread & Rest Syntax | JavaScript Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. JavaScript Course

Lesson 21 of 55

·javascript

Spread & Rest Syntax

7 mins

Course progress38%

What you'll learn

Keep these ideas in mind as you work through the lesson.

3 points
  • Spread can be used for **shallow copies** – nested objects stay linked.
  • `...` must be the **last** parameter in a function signature when used as rest.
  • Both syntax forms improve functional‑style code.

Spread expands an iterable into individual elements.

const a = [1,2];
const b = [...a,3,4]; // [1,2,3,4]

Rest gathers remaining elements into an array.

function sum(...nums){ return nums.reduce((a,b)=>a+b,0); }

Works with objects as well.

const obj1 = {a:1};
const obj2 = {...obj1, b:2}; // {a:1,b:2}
Make it stickPractice what you've learned1 quiz · 7 practical tests · Optional activities from JavaScript CourseBrowse activities
Previous lessonObject Literals, Shorthand & DestructuringContinue to lesson 22Classes – ES6 Syntax, Inheritance, Getters/Setters, staticBack to JavaScript Course curriculum