Developer Cheat Sheets
Quick reference guides, key syntax elements, and interactive code snippets for modern developers.
Variables & Data Types
Python is dynamically typed. You declare variables by assigning values directly, without type specifiers.
# Declaring variables
name = "Fun Koding"
age = 5
is_active = True
numbers = [1, 2, 3, 4] # List
coordinates = (10, 20) # Tuple
user = {"name": "Admin", "role": "Moderator"} # Dict
Understanding Python Types
Python variables function as references to objects in memory. The list type is mutable, meaning you can dynamically append or remove elements. In contrast, tuples represent immutable sequences, offering thread safety and protection against accidental overrides in nested loops. Dictionaries are optimized hash-map implementations providing constant-time O(1) lookups for keyed attributes, supporting advanced configurations in modern developer workflows.
Control Flow & Loops
Python uses indentation for blocks rather than brackets. Common tools include if-elif statements, for loops, and while loops.
# Conditionals and For-Loop
if age > 18:
print("Adult")
elif age > 12:
print("Teen")
else:
print("Child")
for item in numbers:
print(f"Value: {item}")
Indentations and Conditional Flow
In Python, structure is enforced by indentation rather than opening braces. Loop iterations can leverage generator objects via functions like `range()` or custom iterables to maintain minimal memory consumption. Conditional statements assess values truthiness, where empty objects, None, and zero resolve false. Clean loops help frontend and backend scripts process payloads efficiently.
Functions & Lambda Operations
Functions are declared with def. Lambda expressions provide inline, single-expression anonymous functions.
# Regular function
def greet(user_name):
return f"Hello, {user_name}!"
# Inline Anonymous Lambda
multiply = lambda x, y: x * y
print(multiply(3, 5))
Function Scoping & Higher-Order Execution
Python supports positional arguments, keyword arguments, and defaults. Lambda functions represent single-line anonymous operations frequently used in list mappings, filtering operations, and dictionary sorts. Leveraging clear functional patterns promotes modular codebase growth and makes backend scripts easy to write and maintain.
Variables & Scope
Modern JavaScript uses let and const for block scope variables, replacing var.
// Block scoped variables
const name = "Fun Koding";
let age = 5;
let isActive = true;
const items = [1, 2, 3];
const user = { name: "Alex", admin: true };
Scope Rules in ES6+
Unlike `var` which has function-level hoisting rules, `let` and `const` variables are block-scoped, existing only within the enclosing braces. `const` creates a read-only reference, meaning although you cannot reassign it, nested attributes or array contents are mutable unless protected by methods like `Object.freeze()` or helper functions. This ensures solid memory handling and is standard practice in React/Vite web application development.
Arrow Functions & Array Methods
Arrow functions offer short declaration syntax and lexical binding of the this context.
// Arrow Function
const greet = (user) => `Hello, ${user}!`;
// Array mappings
const doubled = items.map(x => x * 2);
const odds = items.filter(x => x % 2 !== 0);
JavaScript Iterations and Higher-Order Methods
Arrow functions bind the `this` keyword lexically, making them the default choice inside callback blocks and event handlers. Array utilities like `map`, `filter`, and `reduce` execute non-mutating updates on target collections. This functional paradigm matches current web practices, allowing developers to clean up standard loops and process JSON payloads instantly.
Asynchronous Programming
Promises and async/await syntax provide clean structures to manage asynchronous behaviors.
// Async-Await fetch request
async function fetchData(url) {
try {
const response = await fetch(url);
const data = await response.json();
return data;
} catch (err) {
console.error(err);
}
}
The JavaScript Event Loop
JavaScript executes asynchronously on a single thread using an Event Loop. The async/await wrapper simplifies promise resolutions by mirroring procedural code readability while maintaining non-blocking properties. This ensures seamless API interactions and prevents standard browser freezing bugs during networking cycles.
Variables & Null Safety
Dart uses strong static typing with sound null safety. Variables must be initialized or explicitly declared nullable.
// Sound null-safe declarations
String name = "Fun Koding";
int age = 5;
double score = 95.5;
bool isActive = true;
String? nullableName; // Can be null
final constList = const [1, 2, 3]; # Immutable
Dart Sound Null Safety
Dart enforces null safety during compile-time. Declaring variables nullable using the `?` token tells the compiler that the parameter can evaluate to null, requiring assertions or fallback operators (`??`) before manipulation. This eliminates the notorious null pointer exception at runtime, ensuring robust, safe, and premium Flutter application code execution.
Classes & Constructors
Dart is object-oriented with support for mixins, multiple constructors, and initializer lists.
// Class structure in Dart
class Developer {
final String name;
final String language;
// Constructor with syntactic sugar
Developer(this.name, this.language);
void code() {
print("$name is compiling $language...");
}
}
Object-Oriented Design in Flutter
Dart uses single inheritance with mixin-based composition, providing a lightweight system to reuse methods without code duplication. Form constructors support initializing attributes directly inside parameters, a layout standard in Flutter widget compositions. This makes Dart incredibly optimized for user interface structures and reactive rendering logic.
Async Programming (Futures)
Dart handles asynchronous computations using Future and Stream types.
// Dart Futures
Future<String> fetchUserRole() async {
await Future.delayed(const Duration(seconds: 2));
return "Admin";
}
void main() async {
final role = await fetchUserRole();
print("Role: $role");
}
Async/Await Lifecycle in Dart
Dart executes async computations on an isolate thread utilizing an Event Loop. Future objects resolve async values, letting mobile apps fetch JSON data or request storage properties without blocking the UI rendering layer. This is essential for a fluid, lag-free user experience on iOS and Android devices built with Flutter.