3 ms·
This seems to work on Python: def hello(a, b = 'world'): print(a, b) hello('hello') hello('hello', 'world') But these don't, so fair point: he
by franciscop 6y ago
This seems to work on Python:
def hello(a, b = 'world'):
print(a, b)
hello('hello')
hello('hello', 'world')
But these don't, so fair point:
hello('hello', 'world', 'there)
# nor
def hello(a):
...
hello('hello', 'world')
- username90 6y agoYeah, problem with JavaScript function signatures is that every function argument is optional, including all the arguments you didn't write. In python those functions would look like: def F(a = None, b = None, *args): ... And you can't write any other kind of function in javascript. I don't really like that aspect of javascript, it creates so many hard to debug situations.
- mechEpleb 6y agoThe first is an example of default argument syntax, it doesn't mean you can call functions with extra arguments, only that a value will be provided from the declaration if the call doesn't.