PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, October 18, 2022

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

 October 18, 2022     function, javascript     No comments   

Issue

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'?


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.



Answered By - Neon
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing