When using the executeScript API, you can use it like this:
executeScript(script/function, arg1, arg2, arg3, ...)
The initial argument can be a JavaScript snippet or a JavaScript function. If it is a snippet, it will be wrapped into a function within executeScript
.
The following arguments are the parameters for the JavaScript function that corresponds to the first argument.
arguments
is a built-in feature in JavaScript functions. It allows you to access the actual arguments passed when calling a function. Check out the example below for clarification:
test('tom', 12, 'male', '175cm') // calling the test function
function test(name, age) {
console.log(name); // tom
console.log(age); // 12
console.log(arguments); // ['tom', 12, 'male', '175cm']
console.log(arguments[0]); // same as name parameter: tom
console.log(arguments[1]); // same as age parameter: 12
console.log(arguments[2]); // male
console.log(arguments[3]); // 175cm
}
For more information on JavaScript Function.arguments