DEV Community

Cover image for Learn JavaScript Default Parameters🔥 - ajaysharma_dev
Knowledge From Twitter
Knowledge From Twitter

Posted on • Edited on • Originally published at infotweets.com

Learn JavaScript Default Parameters🔥 - ajaysharma_dev

Original Tweet From @ajaysharma_dev

It is one of the features of ES6.

When a JavaScript function is called with fewer than the declared number of arguments, the missing values are set to 'undefined.’

Sometimes this is acceptable, but other times it is preferable to provide the argument a default value.

Let's learn the default Parameter with examples. Twitter Image 1

think what will happen if we will not provide the value Twitter Image 2

Here, now we can set the default parameter Twitter Image 3

It also allows default parameter values in the function declaration Twitter Image 4

If you enjoyed reading this thread, please do the following:

  1. Like the thread❤️
  2. Retweet the first tweet.🔃
  3. Follow me and enable notifications: ✅ @ajaysharma_dev Thank you for reading all the way through.
Click Here For More Posts Like This https://www.knowledge-twitter.com

Top comments (0)