Modern JavaScript (ES6+) for Beginners
Lesson 7 of 12 58% of course

Default Parameters & Object Shorthand

1 · 5 min · 6/7/2026

Learn Default Parameters & Object Shorthand in our free Modern JavaScript (ES6+) for Beginners series. Step-by-step explanations, examples, and interview tips on Toolliyo Academy.

Sign in to track progress and bookmarks.

Default Parameters & Object Shorthand
Lesson 7 of 12 · Part 3 — Data & Collections · Modern JavaScript (ES6+) for Beginners
Course: Modern JavaScript (ES6+) for Beginners · Lesson: 7/12 · Read time: ~14 min · Level: Beginner · ES version: ES2015 (ES6) and above

Default Parameters & Object Shorthand

ES6 lets you give function parameters default values and write shorter object literals. Less boilerplate, fewer if (x === undefined) checks.

Default parameters

function createUser(name, role = 'student', active = true) {
  return { name, role, active };
}

createUser('Alex');                    // role student, active true
createUser('Admin', 'admin');          // active still true
createUser('Guest', 'guest', false);

Object property shorthand

const name = 'Node.js Chat Course';
const price = 499;
const currency = 'INR';

// Old
const product1 = { name: name, price: price, currency: currency };

// ES6 shorthand
const product2 = { name, price, currency };

Method shorthand in objects

const api = {
  baseUrl: 'https://api.toolliyo.com',
  getHealth() {
    return fetch(this.baseUrl + '/health');
  }
};
🌍 Real-world example — Send email with optional CC
function buildEmail({ to, subject, body, cc = [] }) {
  return { to, subject, body, cc, sentAt: new Date().toISOString() };
}

buildEmail({
  to: 'student@example.com',
  subject: 'Welcome to Toolliyo',
  body: 'Start with ES6 lesson 1.'
});
⚠️ Common Mistake: Default only triggers for undefined, not null: fn(null) does not use default — pass undefined or omit the argument.
👨‍🏫 Teaching note: Quiz: what does greet(name = "Guest") return when called with greet("")? Empty string — default not used.

Continue learning

Previous: Spread & Rest Operators (...)

Next: Array Methods — map, filter, find & reduce

Course home: All 12 lessons

Test your knowledge

Quizzes linked to this course—pass to earn certificates.

Browse all quizzes
Modern JavaScript (ES6+) for Beginners

On this page

Default parameters Object property shorthand Method shorthand in objects Continue learning
Part 1 — Modern Basics
Introduction — Why ES6+ Before Node.js & React let, const & Block Scope Arrow Functions Explained
Part 2 — Write Less Code
Template Literals & Modern Strings Destructuring — Arrays & Objects Spread & Rest Operators (...)
Part 3 — Data & Collections
Default Parameters & Object Shorthand Array Methods — map, filter, find & reduce for...of, Sets & Maps Essentials
Part 4 — Async & Modules
Promises — then, catch & finally async/await & Fetch API Modules — import/export & What to Learn Next
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details