Filter by the role you are applying for, open a question, and practise explaining the answer out loud. Mark it practised when you can.
Why they ask this: Closures power callbacks, React hooks, module patterns and data privacy, so they show how well you know the language.
Answer
A closure is a function together with the variables from the scope where it was created. The inner function keeps access to those variables even after the outer function has returned.
function makeCounter() {
let count = 0; // private to the closure
return {
increment: () => ++count,
current: () => count,
};
}
const
Why they ask this: Shows whether you understand how async code actually runs, which matters for debugging ordering and UI freezes.
Answer
Why they ask this: Almost every app calls APIs; interviewers check you can write and handle async code correctly.
Answer
Why they ask this: Most React bugs (infinite loops, stale data, memory leaks) come from misusing useEffect.
Answer
Why they ask this: Every team uses Git; this checks you can collaborate without rewriting shared history.
Answer
Why they ask this: Tests whether you can design flexible code rather than only reciting definitions.
Answer
Why they ask this: Checks design maturity; deep inheritance trees are a common source of rigid code.
Answer
Why they ask this: There is no single right answer; interviewers want reasoning, not a favourite library.
Answer
Why they ask this: Misusing BuildContext causes common runtime errors, so this tests deeper Flutter knowledge.
Answer
Why they ask this: Networking, databases and real-time features in Flutter depend on async Dart.
Answer
Why they ask this: Offline support and secure token storage come up in nearly every mobile project.
Answer
Why they ask this: Shows practical debugging experience beyond building happy-path screens.
Answer
Practical uses:
count cannot be changed from outside.const add5 = makeAdder(5).JavaScript runs your code on one thread with a call stack. Async work (timers, network, DOM events) is handled by the browser or Node.js, and their callbacks are queued.
The event loop repeats:
.then, await continuations) and queueMicrotask.setTimeout callback or an event handler, run it, and go back to step 2.console.log('1');
setTimeout(() => console.log('2'), 0);
Promise.resolve().then(() => console.log('3'));
console.log('4');
// Output: 1, 4, 3, 2Microtasks always run before the next timer, even a 0 ms one. A long synchronous loop blocks everything, including clicks and rendering.
A Promise represents a value that will be available later (pending, then fulfilled or rejected). async/await is syntax on top of promises that makes async code read like synchronous code.
// Promise chain
fetch('/api/jobs')
.then((res) => res.json())
.then((jobs) => console.log(jobs))
.catch((err) => console.error(err));
// async/await
async function loadJobs() {
try {
const res = await fetch('/api/jobs');
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return await res.json();
} catch (err) {
console.error(err);
}
}Points worth mentioning:
async function always returns a promise.try/catch for errors with await.await Promise.all([...]) instead of awaiting one after another.useEffect(effect, deps) runs effect after render:
[]: runs once after the first render (mount).[a, b]: runs after the first render and again whenever a or b changes (compared with Object.is).The function you return is the cleanup. It runs before the effect runs again and when the component unmounts. Use it to remove listeners, clear timers and cancel requests.
useEffect(() => {
const controller = new AbortController();
fetch(`/api/jobs?q=${query}`, { signal: controller.signal })
.then((r) => r.json())
.then(setJobs)
.catch(() => {});
return () => controller.abort(); // cancel the old request when query changes
}, [query]);Include every value from the component that the effect uses in the array. Missing dependencies cause stale values.
Both bring changes from one branch into another:
git merge main creates a merge commit that joins the two histories. Nothing is rewritten, so it is safe on shared branches, but the history shows every merge.git rebase main replays your branch's commits on top of main, creating new commits with new hashes. The result is a clean, linear history.git switch feature/login
git fetch origin
git rebase origin/main # update your feature branch
# fix conflicts, then: git add <file> && git rebase --continue
git push --force-with-lease # needed because history changedGolden rule: never rebase commits that other people have already pulled (such as main). Rebase your own feature branch; merge into shared branches, usually through a pull request.
| Interface | Abstract class | |
|---|---|---|
| Contains | method signatures (and constants) | abstract and implemented methods, plus properties |
| A class can use | many interfaces | only one parent class (in PHP, Java and Dart) |
| Constructor and state | no | yes |
| Meaning | "can do" (a capability) | "is a" (a shared base) |
Cacheable, PaymentGateway.Report base class with an abstract rows() method.In PHP you can combine both, and use traits to share code horizontally. Dart has no interface keyword in older versions: every class can be implemented with implements, and Dart 3 adds interface class.
// Inheritance: every new notification channel needs a new subclass
class SmsOrderNotifier extends OrderNotifier { /* ... */ }
// Composition: inject the channel
final class OrderNotifier
{
public function __construct(private NotificationChannel $channel) {}
public function notify(Order $order): void
{
$this->channel->send($order->customer, "Order #{$order->id} confirmed");
}
}Inheritance is still fine for a true, stable "is a" relationship with shared behaviour. Flutter is a good example of composition: UIs are built by nesting small widgets rather than extending big ones.
setState: local state inside one widget. Simple and perfectly fine for small screens.InheritedWidget / ValueNotifier + ValueListenableBuilder: built into Flutter and lightweight.InheritedWidget. Good for simple app-wide state, such as the logged-in user or the theme.BuildContext. Good for async data and testing.How to choose: keep state as local as possible. Pick a shared solution when several screens need the same data. Consider the team's experience, how testable it is, and how much boilerplate you can accept. Be ready to explain one approach in depth with code from a project you built.
A BuildContext is a handle to a widget's location in the widget tree (it is actually the widget's Element). It is used to look up the tree for inherited data and services:
final theme = Theme.of(context);
final size = MediaQuery.sizeOf(context);
Navigator.of(context).push(MaterialPageRoute(builder: (_) => const JobScreen()));
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Saved')));Common pitfalls:
Scaffold.of(context) fails if context belongs to a widget above the Scaffold. Wrap the child in a Builder to get a context below it.await, the widget may have been removed. Check if (!context.mounted) return; before using the context again.Future<T> delivers one value (or an error) later, such as an HTTP response. Use it with async/await or FutureBuilder.Stream<T> delivers many values over time, such as location updates, Firestore snapshots, WebSocket messages or user input. Use it with await for, listen() or StreamBuilder.Future<List<Job>> fetchJobs() async {
final res = await http.get(Uri.parse('https://api.example.com/jobs'));
if (res.statusCode != 200) throw Exception('Failed: ${res.statusCode}');
return (jsonDecode(res.body) as List).map((j) => Job.fromJson(j)).toList();
}
Stream<int> countdown(int from) async* {
for (var i = from; i >= 0; i--) {
await Future.delayed(const Duration(seconds: 1));
yield i;
}
}Always cancel stream subscriptions in dispose() to avoid memory leaks.
Choose storage by what you are saving:
@react-native-async-storage/async-storage): simple, unencrypted key-value storage for small, non-sensitive data such as settings or onboarding flags.react-native-mmkv): a much faster key-value store, also synchronous.expo-secure-store or react-native-keychain, which use the iOS Keychain and the Android Keystore.expo-sqlite), WatermelonDB or Realm.import * as SecureStore from 'expo-secure-store';
await SecureStore.setItemAsync('auth_token', token);
const saved = await SecureStore.getItemAsync('auth_token');Never put access tokens in AsyncStorage, and never ship API secrets inside the app bundle, because the bundle can be unpacked.
Measure first:
Common fixes:
FlatList (or FlashList) with stable keys instead of mapping long arrays in a ScrollView.React.memo, useCallback and useMemo, and keep state close to where it is used.expo-image.useNativeDriver: true.console.log calls from release builds.