Zet - A good cheat sheet table highlighting some of the key syntax differences between JavaScript, Python, and Lua:
A good cheat sheet table highlighting some of the key syntax differences between JavaScript, Python, and Lua:
| Feature | JavaScript | Python | Lua |
|---|---|---|---|
| Variable Declaration | let x = 10; | x = 10 | x = 10 |
| Function Definition | function myFunc() {} | def my_func(): | function my_func() |
| Conditionals | if (x > 0) {} | if x > 0: | if x > 0 then |
| Loops | for (let i = 0; i < 10; i++) {} | for i in range(10): | for i = 1, 10 do |
| Arrays/List | let arr = [1, 2, 3]; | arr = [1, 2, 3] | arr = {1, 2, 3} |
| Dictionaries/Tables | let obj = {key: "value"}; | dict = {"key": "value"} | tbl = {key = "value"} |
| Comments | // Single line and /* Multi-line */ | # Single line & ''' Multi-line ''' | -- Single line and --[[ Multi-line ]] |
| String Concatenation | let str = "Hello " + "World"; | str = "Hello " + "World" | str = "Hello " .. "World" |
| Error Handling | try { /* code */ } catch (e) {} | try: ... except Exception as e: | status, err = pcall(function() ... end) |
| Boolean Values | true, false | True, False | true, false |
| String Interpolation Syntax | `Hello, ${name}!` | f"Hello, {name}!" | string.format("Hello, %s!", name) |
#lua #python #javascript