Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Calculator

0

82
Views
Can we create a function that takes optional arguments but can skip some arguments?

For example:

function test(isNew="not new", isOwned="not owned", isRed=null){
 console.log(`${isNew}, ${isOwned}, and ${isRed}`);
}

Supposing I wanted to set only isRed to a certain value... How would I achieve that and omit the rest to get the following:

test(isRed="not red") // not new, not owned, and not red

Thank you.

7 months ago ยท Juan Pablo Isaza
Answer question
Find remote jobs