Is there a way to print arguments' list in full or in parts in JavaScript?
Example:
from within the function my_assert(a!=b)
I'd like to print a!=b
, or even 2!=3
for a particular function call.
arguments is an Array -like object accessible inside functions that contains the values of the arguments passed to that function.
It's a native JavaScript object. You can access specific arguments by calling their index. var add = function (num1, num2) { // returns the value of `num1` console. log(arguments[0]); // returns the value of `num2` console.
Syntax *args allow us to pass a variable number of arguments to a function. We will use len() function or method in *args in order to count the number of arguments of the function in python.
Using typeof operator, we can get the type of arguments passed to a function.
you can't. a!=b
is executed first and only the result of this (true
or false
) is given to your function so you don't have a chance to get back a!=b
or 2!=3
.
console.log (arguments)
will print the arguments given to the function, but in your case, all your function sees is a boolean, because a != b
will be evaluated first, and only the result passed as a parameter in the function call.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With