Skip to content

From Python to Javascript

Maciej Jankowski edited this page Sep 13, 2018 · 2 revisions

Python is a great language, but Javascript is too. I will show

Functions

def what_the_f(the_f):
  return str(the_f) + 'is fine'

lambda the_f : str(the_f) + 'is_fine'
function whatTheF(theF){
  return String(theF) + 'is fine';
}

(theF) => String(theF) + 'is fine';

for loops & family

for element in elements_list:
  print('elemenelement', element)
for (let element in elementsList){ // this is tricky
  console.log('elemenelement', element);
}

for (let element of elementList){
  console.log('elemenelement', element);
}

// this is useful for HTMLCollection which is tricky
for (let i = 0; i < elementList.length; i++){

}

Clone this wiki locally