- 1

Can JAVASCRIPT have function overloading??

2nd Aug 2017, 9:52 AM
ayush
ayush - avatar
5 Answers
+ 3
Function overloading make sense only in typed languages, but JS is duck typing one, so there's no difference between a function expecting a specific type of argument: overloading is needed to differenciate function to be run regarding it's context arguments, what you would do rather by testing the type of arguments inside function in JS... In the other hand, you can have function overwritting, just by redefining even built-in functions: document.write = function(s) { console.log(s); } will bypass the standard document.write() execution and redirect output to console ^^
2nd Aug 2017, 11:58 AM
visph
visph - avatar
+ 2
@ayush: Why marking my answer as best, then unmarking it and set it again to @Jordan?... all the more without upvoting any? @@
2nd Aug 2017, 12:17 PM
visph
visph - avatar
2nd Aug 2017, 11:23 AM
Jordan Chapman
Jordan Chapman - avatar
+ 1
thanks jordan
2nd Aug 2017, 11:24 AM
ayush
ayush - avatar
- 1
@visph sorry i was unaware , i think it was pressed by mistake
2nd Aug 2017, 12:19 PM
ayush
ayush - avatar