Can I "access" a specific parameter of a JavasScript function, ie give a value for a given parameter? As an example is better than text (since I can not explain myself right), here's one:
In Python, having a function:
def funcX(A="A",B="B",C="C"):
print(A+B+C)
... that would result in:
'ABC'
... I can change the value of a certain parameter like this:
funcX(C = "c")
... which results in:
'ABc'
I want to know if there is any way to do the same in JavaScript. Example:
function funcX(A,B,C){
if(typeof A != 'string'){A= "A"}
if(typeof B != 'string'){B= "B"}
if(typeof C != 'string'){C= "C"}
alert(A+B+C)
};
It would result in:
'ABC'
And then I would like to do something like:
funcX(C = "c")
... to result in:
'ABc'
Taking advantage of this, I'd like to ask a parallel question (if that's allowed):
Is there a better way to give "default values" for JavaScript function parameters than if(typeof A != 'string'){A= "A"}
?
As in Python def funcX(A="A")
* (sorry for the comparison, but I learned to program in Python, and that's the only reference I have)