Combining Default and Custom Options in Typescript

Image by Pexels from Pixabay



const RANGE_DEFAULT_OPTIONS = { min: 0, max: 100 }

And we want to use the defaults, unless the API overrides them:

export function range(value:number, options:any) {


options = { ...RANGE_DEFAULT_OPTIONS, ...options }


Founder of Firefly Semantics Corporation

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Building a Mobile App Backend using Node.js and MongoDB.

Netlify — Client Side Routing

Comparing Frontend Frameworks for Spring Boot: React, Angular, and Vaadin (+JHipster)

step by step guide tell you how to build a website like apkmirror

Kickstart your next project with this Starter Kit

Selectors-Actions-Hooks architecture with Redux Toolkit

JavaScript only

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ole Ersoy

Ole Ersoy

Founder of Firefly Semantics Corporation

More from Medium

Formatting Javascript Strings and Numbers to 2 Decimal Places

JavaScript Control Flow & Error Handling

Build CRUD on RESTful API with MongoDB — Javascript, Part2— Setup the project.

JavaScript string methods. [part — 3]