TechHire NepalConnecting Talent, Building Careers
Find JobsCompaniesCourses
Find Talents
Sign inGet Started →
Find JobsCompaniesCourses
Find Talents
Sign inGet StartedHire Talent
TechHire Nepal

Nepal's #1 tech job platform. Connecting top talent with the best companies.

For Job Seekers

  • Browse Jobs
  • Companies
  • Tech Salaries
  • Interview Prep
  • Courses
  • Career Advice

For Employers

  • Post a Job
  • Talent Search
  • Pricing
  • Employer Dashboard

Company

  • About
  • Blog
  • Careers
  • Contact

Resources

  • Training Institutes
  • Projects
  • Tutorials
  • Roadmaps
  • Notes
  • Open Sources

Community

  • Discussions
  • Tech Events
  • Hackathons
  • Developer Meetups
  • Tech News

More

  • Help & Support
  • Salary Tax Calculator
  • Company Registration Guide
  • Labour Act

Stay in the loop

A weekly digest of the best tech articles and jobs in Nepal.

© 2026 TechHire Nepal. All rights reserved.

Privacy PolicyTerms of ServiceCookie Policy
HomeInterview PrepQuestion bank
Question bank

Interview Questions, Answered Clearly

Filter by the role you are applying for, open a question, and practise explaining the answer out loud. Mark it practised when you can.

Type
TechnicalCodingHR / BehaviouralAll types
Role
All rolesFrontend DeveloperBackend DeveloperFull-Stack DeveloperMobile Developer
Topic
All topicsJavaScript10React7HTML & CSS7PHP & Laravel9SQL & Databases6HTTP & REST APIs6Git4OOP & Design4Flutter5React Native5Arrays & Hashing4Strings3Searching & Stacks2Logic Basics1HR Basics9Behavioural (STAR)3
Level
AnyEasyMediumHard

10 questions

  • Why they ask this: Checks that you understand scope and hoisting, which explain many real bugs in JavaScript code.

    Answer

    • var is function-scoped, is hoisted and initialised to undefined, and can be re-declared.
    • let is block-scoped ({ ... }), is hoisted but sits in the temporal dead zone until its declaration runs, and cannot be re-declared in the same scope.
    • const behaves like let but the binding cannot be reassigned. The value itself is not frozen: you can still change an object's properties or push to an array.
    js
    for (var i = 0; i < 3; i++) setTimeout(() => console.log(i)); // 3 3 3
    for (
    
    
    
    
    Open full page
  • 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.

    js
    function makeCounter() {
      let count = 0; // private to the closure
      return {
        increment: () => ++count,
        current: () => count,
      };
    }
    
    const
    
    
    
    Open full page
  • Why they ask this: Loose equality causes subtle bugs; interviewers want to see that you default to strict comparison.

    Answer

    Open full page
  • Why they ask this: Shows whether you understand how async code actually runs, which matters for debugging ordering and UI freezes.

    Answer

    Open full page
  • Why they ask this: A classic fundamentals check that also reveals whether you understand let/const and the temporal dead zone.

    Answer

    Open full page
  • Why they ask this: Bugs with lost this in callbacks are common, and the answer shows depth beyond syntax.

    Answer

    Open full page
  • Why they ask this: Almost every app calls APIs; interviewers check you can write and handle async code correctly.

    Answer

    Open full page
  • Why they ask this: A quick fundamentals question that checks attention to detail.

    Answer

    Open full page
  • Why they ask this: Tests your understanding of DOM event bubbling and performance with dynamic lists.

    Answer

    Open full page
  • Why they ask this: Common in search boxes, scroll and resize handlers; shows you think about performance.

    Answer

    Open full page
let
j
=
0
; j
<
3
; j
++
)
setTimeout
(()
=>
console.
log
(j));
// 0 1 2
const user = { name: 'Sita' };
user.name = 'Ram'; // allowed
// user = {}; // TypeError: Assignment to constant variable

Rule of thumb: use const by default, let when you must reassign, and avoid var in modern code.

counter
=
makeCounter
();
counter.increment();
counter.increment();
console.log(counter.current()); // 2

Practical uses:

  • Data privacy: count cannot be changed from outside.
  • Function factories, for example const add5 = makeAdder(5).
  • Callbacks and event handlers that remember values.
  • React hooks: every render's handlers close over that render's state, which is why stale state bugs happen.
  • === (strict equality) compares value and type. No conversion happens.
  • == (loose equality) converts the operands to a common type first, then compares.
js
0 == '0'          // true  (string converted to number)
0 === '0'         // false (number vs string)
null == undefined // true
null === undefined// false
'' == 0           // true

Always use === (and !==) unless you deliberately want conversion. A common, accepted exception is value == null, which checks for both null and undefined.

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:

  1. Run the current script until the call stack is empty.
  2. Run all microtasks: promise callbacks (.then, await continuations) and queueMicrotask.
  3. Let the browser render if needed.
  4. Take one macrotask (task) such as a setTimeout callback or an event handler, run it, and go back to step 2.
js
console.log('1');
setTimeout(() => console.log('2'), 0);
Promise.resolve().then(() => console.log('3'));
console.log('4');
// Output: 1, 4, 3, 2

Microtasks always run before the next timer, even a 0 ms one. A long synchronous loop blocks everything, including clicks and rendering.

Hoisting means declarations are processed before code runs, so they are known in their whole scope.

  • Function declarations are hoisted with their body, so you can call them before they appear.
  • var is hoisted and initialised to undefined.
  • let, const and class are hoisted too, but stay uninitialised (the temporal dead zone) until the declaration line runs. Accessing them earlier throws a ReferenceError.
js
greet();            // works
function greet() { console.log('Namaste'); }

console.log(a);     // undefined
var a = 1;

console.log(b);     // ReferenceError
let b = 2;

Function expressions (const greet = () => {}) follow the rules of the variable they are assigned to.

this depends on how a function is called, not where it is written:

Call stylethis
obj.method()obj
plain fn()undefined in strict mode (the global object otherwise)
new Fn()the new object
fn.call(x) / fn.apply(x) / fn.bind(x)x
arrow functionthis of the surrounding scope (arrows have no own this)
js
const user = {
  name: 'Hari',
  hello() { return this.name; },
  later() { setTimeout(() => console.log(this.name)); }, // arrow keeps `this`
};

const fn = user.hello;
fn(); // `this` is lost: undefined in strict mode

Fix lost this with an arrow function or .bind(obj).

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.

js
// 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:

  • An async function always returns a promise.
  • Use try/catch for errors with await.
  • Run independent requests in parallel with await Promise.all([...]) instead of awaiting one after another.
  • undefined means a value was never assigned: an uninitialised variable, a missing object property, a missing function argument, or a function with no return.
  • null is an intentional "no value" that a developer assigns.
js
let a;              // undefined
const obj = {};
obj.missing;        // undefined
let b = null;       // explicitly empty

typeof undefined;   // 'undefined'
typeof null;        // 'object' (a historical bug)
null == undefined;  // true
null === undefined; // false

Use ?? (nullish coalescing) to give a default for both: const name = input ?? 'Guest'.

Most DOM events bubble up from the target element to its ancestors. Event delegation puts one listener on a parent and uses event.target to work out which child was clicked.

js
document.querySelector('#todo-list').addEventListener('click', (event) => {
  const button = event.target.closest('button.delete');
  if (!button) return;
  button.closest('li').remove();
});

Benefits:

  • One listener instead of hundreds, which uses less memory.
  • Works for elements added later, with no need to re-attach listeners.

Use event.stopPropagation() carefully, because it breaks delegation for listeners higher up.

Both limit how often a function runs:

  • Debounce: run the function only after events stop for a given time. Typical use: a search box that calls the API 300 ms after the user stops typing.
  • Throttle: run the function at most once per interval while events keep firing. Typical use: a scroll handler that runs every 200 ms.
js
function debounce(fn, delay = 300) {
  let timer;
  return (...args) => {
    clearTimeout(timer);
    timer = setTimeout(() => fn(...args), delay);
  };
}

const onSearch = debounce((q) => fetch(`/api/search?q=${encodeURIComponent(q)}`));