JavaScript Cheatsheet for Python Developers
Variables
Python: x = 10
JavaScript: let x = 10; // or var x = 10; or const x = 10;
Data Types
Python: int, float, str, list, dict
JavaScript: number, string, boolean, array, object
Printing Output
Python: print('Hello')
JavaScript: [Link]('Hello');
Conditionals
Python:
if x > 5:
print('Big')
else:
print('Small')
JavaScript:
if (x > 5) {
[Link]('Big');
} else {
[Link]('Small');
Loops
Python:
JavaScript Cheatsheet for Python Developers
for i in range(5):
print(i)
JavaScript:
for (let i = 0; i < 5; i++) {
[Link](i);
Functions
Python:
def greet(name):
return 'Hello ' + name
JavaScript:
function greet(name) {
return 'Hello ' + name;
Arrays and Lists
Python: my_list = [1, 2, 3]
JavaScript: let myArray = [1, 2, 3];
Dictionaries vs Objects
Python: person = {'name': 'John', 'age': 30}
JavaScript: let person = {name: 'John', age: 30};
Null and Undefined
Python: None
JavaScript: null, undefined
JavaScript Cheatsheet for Python Developers
Boolean Logic
Python: and, or, not
JavaScript: &&, ||, !