Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What does it mean to call a function/method variadic?

I was reading a blog article about Puppeteer(A Node Library that helps with browser automation) in which it said the following,

"You can append one or more arguments to page.evaluate since it’s
variadic in what it accepts."

What quality about a function makes it ‘variadic’?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

A variadic function is a function where the total number of parameters are unknown and can be adjusted at the time the method is called.

Basically if the number of parameters are unknown then it’s variadic.

It can be done using rest parameters, any number of parameters can be passed. Below, myFunction can have any number of parameters.

myFunction(...iterableObj)

Same also applies for console.log(), you can pass any number of parameters in it which makes it variadic.

Talking about Page.evaluate in specific, from its documentation, it also accepts rest parameters making it variadic.

The second parameter args is a rest parameter.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading