Jul-05-2021, 12:30 AM
(Jul-04-2021, 05:15 PM)alok Wrote: Thank You,as I said and from what you gave as demo ,to do the same function like Hello World , in Python , C++ or JavaScript, the three all use different code to produce the same outcome,correct ?Yes the produce the same output,but the usage languages can different task as eg JavaScript run mostly in Browser.
If I am correct ,why was this done this way ?
(Jul-04-2021, 05:15 PM)alok Wrote: A person that learns say Python and knows nothing else would not be able to program with say JavaScript until he or she learned JavaScript ,correct ?If know Python then JavaScript is similar is not that big a difference.
If i just copy some JavaScript code from web.
function returnSum(first, second) { var sum = first + second; return sum; } var firstNo = 78; var secondNo = 22; console.log(firstNo + " + " + secondNo + " = " + returnSum(firstNo,secondNo));
Output:78 + 22 = 100
Can easily write this in Python.def return_sum(first, second): mysum = first + second return mysum firstNo = 78 secondNo = 22 print(f'{firstNo} + {secondNo} = {return_sum(firstNo, secondNo)}')
Output:78 + 22 = 100
So the output is the same.JavaScript is popular for web-development as together with HTML/CSS it can use Brower for output.
So different langue can have different usage even it outcome is the same.