I am new to JavaScript based on Python background. In Python, parameters can be passed as a key and value as such:
def printinfo( name, age = 35 ):
print "Name: ", name
print "Age ", age
return;
Then the function could be called such:
printinfo( age=50, name="miki" )
printinfo( name="miki" )
Can such parameters pass in JavaScript functions?
I want to be able to pass one or more parameters. For example, a JavaScript function as such:
function plotChart(data, xlabel, ylabel, chart_type="l"){
...
}
I want to be able to transfer only data, and the type of chart and labels are optional, for example:
plotChart(data, chart_type="pie")
Is this possible with JavaScript?
source
share