+ 6

Why the following code works in js but not in python?

So any explanation on why is the following happening and what's the reason behind it to not implement the same in both languages?Ty in advance! https://code.sololearn.com/WRRcQHO2xqO7/?ref=app https://code.sololearn.com/cdUhN68i2rin/?ref=app

7th Sep 2020, 11:01 AM
Abhay
Abhay - avatar
27 ответов
7th Sep 2020, 11:10 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 5
Js function doesnt care how many argument you're giving it to. It'll only take what it can take and ignore the rest. Python in the otherhand is care a lot about the parameter. its like your friend that you cant recognize when he wearing a suit
7th Sep 2020, 11:10 AM
Rei
Rei - avatar
+ 4
Abhay as much as i lovr javascript, javascript history feels like a joke. some article says the entire language was done in a week, its amazing but sure raises some question. Then microsoft releasing its own JScript, the browser wars happen. Somehow es4 adopted in macromedia/adobe flash. It might be just a fragment from the past, who knows.
7th Sep 2020, 11:41 AM
Rei
Rei - avatar
+ 4
If I was to speculate... I'd guess it has to do with how Javascript implements calling bound functions, which may or may not explicitly define parameters. ECMAScript specs state bound functions must contain a special exotic arguments object in the local function scope. This may be how Javascript supported optional arguments before supporting ES6 rest(...args). If understanding this at a deeper level truly is important to you, I'm sure you might be able to extrapolate more about the inner workings of the language starting with these links below: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments https://tc39.es/ecma262/#sec-arguments-exotic-objects Abhay Good luck on your quest. I hope this helps. 👌
8th Sep 2020, 6:13 AM
David Carroll
David Carroll - avatar
+ 3
From my point of view. JavaScript is very unclean. Bugs hide easily. And most of the bugs in JS are because of the unexpected functionality of JS.
7th Sep 2020, 5:39 PM
Terminal_Phantom
Terminal_Phantom - avatar
+ 3
Abhay Unless this question is answered by one of the few with firsthand knowledge behind the rationale of such language design decisions or the reason can be pulled from some credible archived source or provided in the specs , it's an open ended question. At best, the answers will be based on speculation and most likely, answers will be based on a lot of wild guesses and unhelpful commentary from people who are simply less familiar or uniformed about one or both languages. Even if you did get a definitive answer for this question, what would you do with that knowledge? Perhaps this is a distraction from the more important objectives of learning. While there are cases where asking the why would be helpful, I don't believe there is much benefit with this one. But that's just my opinion. 😉 That said...
8th Sep 2020, 6:08 AM
David Carroll
David Carroll - avatar
+ 3
Also... I recommend digging deeper into understanding how Javascript implements lexical environments, variable scopes (global, local function, block), named parameters, and undefined values for arguments that are explicitly passed in as undefined or simply omitted and therefore undefined. This will likely get you closer to being able to infer the rationale for the language design decisions.
8th Sep 2020, 6:23 AM
David Carroll
David Carroll - avatar
+ 2
~ swim ~ that doesn't answers my question about why python doesn't supports passing arguments without the need of defining a parameter like JavaScript
7th Sep 2020, 11:54 AM
Abhay
Abhay - avatar
+ 2
def add(x): return x print(str(add(add(5)))) ☕🤠
9th Sep 2020, 4:24 AM
Sanjay Kamath
Sanjay Kamath - avatar
+ 1
CarrieForle thks and I know that but I still can't understand why is it so!? While in languages like python it is not
7th Sep 2020, 11:22 AM
Abhay
Abhay - avatar
+ 1
~ swim ~ so should I delete the question?
7th Sep 2020, 12:23 PM
Abhay
Abhay - avatar
+ 1
David Carroll I get it that it's an open-ended question and I shouldn't have used Q&A for this ,didn't realise it while asking ,simply wanted to know the benefit of implementing different design in both languages,ty very much for the info tho :)
8th Sep 2020, 7:08 AM
Abhay
Abhay - avatar
+ 1
Sanjay Kamath that's not what I asked ,I know how arguments and parameters work in python ,
10th Sep 2020, 12:43 PM
Abhay
Abhay - avatar
+ 1
0101001101000001 see the question and script that is being used to execute the code
10th Sep 2020, 12:44 PM
Abhay
Abhay - avatar
+ 1
Parshant Kumar either delete the comment or I will report you ✌️
10th Sep 2020, 12:45 PM
Abhay
Abhay - avatar
+ 1
Please follow me and be my friend
10th Sep 2020, 1:53 PM
Prashant Kumar
Prashant Kumar - avatar
10th Sep 2020, 2:31 PM
Kamal Panara
Kamal Panara - avatar
0
Parshant Kumar Delete the answer or else I will report about you
9th Oct 2020, 6:53 AM
Yuvraj Singh Sandhu (Inactive)
Yuvraj Singh Sandhu (Inactive) - avatar
- 1
Ц сц
8th Sep 2020, 4:37 PM
Nikita Kan
Nikita Kan - avatar
- 2
Hello guys, please i need help in adding a small feature to my mql4 file, please help
7th Sep 2020, 2:07 PM
Temple Alacoco
Temple Alacoco - avatar