yoklainterview sim

Mobile Rn Javascript Typescript Fundamentals Interview Questions

75 verified Mobile Rn Javascript Typescript Fundamentals interview questions — solve with answers, learn from explanations, test yourself in a real simulation.

Try the real simulation →

Sample questions

Rn Javascript Typescript FundamentalsDifficulty 1
In a React Native screen component, what is a closure?
  • aA function that automatically runs when the component unmounts.
  • bA copy of a component's props that never changes after the first render.
  • cA function that retains access to variables from the scope it was defined in, even after that scope has finished executing.
  • dA special React Native API for closing native modules after use.
Explanation:A closure is a function bundled together with references to its surrounding lexical scope. In RN this is why, for example, a callback passed to a Button onPress can still read a variable declared in the component function body.
Rn Javascript Typescript FundamentalsDifficulty 2
const user = {
  name: 'Ada',
  greet: function () {
    return `Hi, ${this.name}`;
  },
};
const fn = user.greet;
fn();

What does calling fn() return (in a React Native/Hermes JS environment, non-strict interop aside, this is undefined)?
  • a"Hi, Ada", because this in a regular function always refers to the object it was originally defined on.
  • bIt throws, because this is undefined inside fn and this.name fails.
  • c"Hi, undefined", because this becomes the global object and name is not a global variable.
  • dIt returns "Hi, " with an empty string, because Hermes defaults unresolved this properties to empty string.
Explanation:Regular functions get this from how they are called, not where they are defined. Assigning user.greet to fn and calling fn() calls it as a plain function, so this is undefined in Hermes/strict ES module code, and accessing this.name throws a TypeError.
Rn Javascript Typescript FundamentalsDifficulty 2
console.log('start');
setTimeout(() => console.log('timeout'), 0);
Promise.resolve().then(() => console.log('promise'));
console.log('end');

What is the logged order?
  • astart, end, promise, timeout
  • bstart, end, timeout, promise
  • cstart, promise, timeout, end — because promises always run before synchronous code finishes.
  • dstart, timeout, promise, end
Explanation:Synchronous code runs first (start, end). Then the microtask queue (Promise callbacks) drains before the macrotask queue (setTimeout callbacks), so promise logs before timeout.
Rn Javascript Typescript FundamentalsDifficulty 1
When you write const arr = [1, 2, 3]; arr.map(x => x * 2), how does arr.map get resolved if Array.prototype doesn't directly define map on arr itself?
  • aIt doesn't resolve; map must be manually copied onto every array instance by the JS engine at creation time.
  • bThe engine walks up the prototype chain from arr to Array.prototype, where map is found and used.
  • cReact Native's Hermes engine injects map globally onto every variable regardless of type.
  • dTypeScript's compiler inlines map's implementation directly into the compiled JS at build time.
Explanation:JS objects (arrays included) have an internal [[Prototype]] link. Property/method lookup walks this chain until it finds the property or reaches null. arr's prototype is Array.prototype, which defines map.
Rn Javascript Typescript FundamentalsDifficulty 2
function wrapInArray<T>(value: T): T[] {
  return [value];
}
const result = wrapInArray(42);

What is the inferred type of result?
  • aany[], because TypeScript cannot infer generic types from function arguments.
  • bT[], literally, since T stays a placeholder until a type annotation is added.
  • cunknown[], because generics default to unknown when the call site provides a primitive.
  • dnumber[], because TypeScript infers T as number from the argument 42.
Explanation:TypeScript performs generic type inference from the call arguments: passing 42 makes T resolve to number, so the return type T[] becomes number[].
Rn Javascript Typescript FundamentalsDifficulty 2
async function loadProfile() {
  const res = await fetch('/api/profile');
  const data = await res.json();
  return data.name;
}

What does calling loadProfile() actually return?
  • aThe string value of data.name directly, synchronously.
  • bundefined, because async functions cannot return values, only side effects.
  • cA fetch response object wrapping data.name.
  • dA Promise that resolves to the value of data.name.
Explanation:An async function always returns a Promise, regardless of what its body returns. Callers need await loadProfile() or .then(...) to access the resolved name value.

Test yourself against the 2400-question Mobile bank.

Start interview