67
rated 0 times
[
70]
[
3]
/ answers: 1 / hits: 23874
/ 9 Years ago, mon, december 21, 2015, 12:00:00
I'm new to JavaScript coming from Python background. In Python parameters can be passed as key and value as such:
def printinfo( name, age = 35 ):
print Name: , name
print Age , age
return;
Then the function could be called as such:
printinfo( age=50, name=miki )
printinfo( name=miki )
Can such parameters be passing in JavaScript functions?
I want to be able to pass one or more parameter. For example a JavaScript function as such:
function plotChart(data, xlabel, ylabel, chart_type=l){
...
}
I want to be able to pass only data and chart type and labels are optional such as :
plotChart(data, chart_type=pie)
Is this possible with JavaScript?
More From » named-parameters