DEV Community

Similar functions in JavaScript and Python

Chan Ho Ahn on November 25, 2018

There are some similarities between computer languages. The two most popular computer languages in these days are probably JavaScript and Python....
Collapse
 
lyfolos profile image
Muhammed H. Alkan • Edited

I want to be sure but don't think I'm saying you're not good: Do you have any good knowledge with Python or Functional Programming? The wrong parts are

  • Params is shortened version of "Parameters" and you just did get only one parameter.

  • PEP8 - Function names should be lowercase, with words separated by underscores as necessary to improve readability. ("funcName" to "func_name")

  • What are [ comment ]? You just have to use comments! // for JS, # for Python.

  • Why adding space between lambda and map function? (map( lambda x: x * 2, nums))

  • Dude its not ▇▇▇▇▇▇▇ lambda function, its just lambda (anonymous function)!

  • JS and Python lambdas have no any similarities, in my opinion, even Java has more similar lambdas to JS. If you're meaning the feature that lambdas give you, almost every modern haves this feature.

  • Almost every languages map, filter, reduce is similar.

Collapse
 
moz5691 profile image
Chan Ho Ahn

I am very appreciated of your comment. Read some of your post. You seem to have good understanding of functional programming. Following your comment, have made some corrections. Thank you. :)

Collapse
 
lyfolos profile image
Muhammed H. Alkan

No problem!

Collapse
 
ansegundo profile image
Alberto Segundo

In the first python map example, shouldn't it be:

 doubles = map(double, nums)

As in, function double, instead of variable doubles

Collapse
 
moz5691 profile image
Chan Ho Ahn

You're right... I have fixed it. Thank you!!!

Collapse
 
eduardomazolini profile image
Eduardo

doubles = [num * 2 for num in nums]
evens = [num for num in nums if num % 2 == 0]

Is not convert js to python is for by pythonic