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 Native5
Level
AnyEasyMediumHard

29 questions

  • 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 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.
    Open full page
  • Why they ask this: The most common Eloquent performance bug; it shows you think about the queries your code runs.

    Answer

    The N+1 problem happens when you load a list (1 query) and then run one more query per item to load a relationship (N queries).

    php
    // 1 query for posts + 1 query per post for its author = N+1
    $posts = Post::all();
    foreach ($posts as $post) {
        echo $post->author->name;
    }

    Fix it with eager loading, which loads the relationship for all rows in one extra query:

    php
    $posts = Post::with('author')->get();           // 2 queries in total
    $posts = Post::with(['author', 'comments'])->get();
    $count = Post::withCount('comments')->get();     // comments_count without loading them

    Find N+1 problems with Laravel Debugbar or Telescope, or make them fail loudly in development with Model::preventLazyLoading(! app()->isProduction());.

    Open full page
  • Why they ask this: An open-ended classic that shows how broad your understanding of the web is.

    Answer

    1. URL parsing: the browser works out the scheme (https), host and path.
    2. DNS lookup: the hostname is resolved to an IP address (browser cache → OS cache → resolver → root, TLD and authoritative name servers).
    3. TCP connection to the server on port 443 (a three-way handshake). HTTP/3 uses QUIC over UDP instead.
    4. TLS handshake: the server proves its identity with a certificate and both sides agree on encryption keys.
    5. HTTP request: for example GET /jobs with headers and cookies.
    6. Server side: a load balancer or web server (Nginx) passes the request to the app (Laravel or Node), which may query the database and returns a response, often via a CDN cache.
    7. Rendering: the browser parses HTML into the DOM and CSS into the CSSOM, runs JavaScript, builds the render tree, then does layout and paint.
    8. Extra requests load images, scripts and fonts, and caching headers decide what is reused next time.

    Go deeper on whichever part matches the role you are applying for.

    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

    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.

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

    Answer

    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).

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

    Answer

    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.
    Open full page
  • Why they ask this: Tests your understanding of DOM event bubbling and performance with dynamic lists.

    Answer

    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.

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

    Answer

    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)}`));
    Open full page
  • Why they ask this: Most React bugs (infinite loops, stale data, memory leaks) come from misusing useEffect.

    Answer

    useEffect(effect, deps) runs effect after render:

    • No array: runs after every 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.

    jsx
    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.

    Open full page
  • Why they ask this: Forms are in every app; this shows how you handle user input and validation.

    Answer

    • Controlled: React state is the single source of truth. The input's value comes from state and every change goes through onChange.
    • Uncontrolled: the DOM keeps the value. You read it when needed with a ref or from the form data on submit.
    jsx
    // Controlled
    const [email, setEmail] = useState('');
    <input value={email} onChange={(e) => setEmail(e.target.value)} />
    
    // Uncontrolled
    const inputRef = useRef(null);
    <input ref={inputRef} defaultValue="" />
    // later: inputRef.current.value

    Choose controlled inputs for instant validation, formatting or conditional UI. Uncontrolled inputs are simpler for basic forms and file inputs (<input type="file"> is always uncontrolled). Form libraries such as React Hook Form mostly use uncontrolled inputs for performance.

    Open full page
  • Why they ask this: Explains "why is my style not applying?" problems that every frontend developer hits.

    Answer

    When several rules target the same element, the browser picks the one with the highest specificity. If specificity is equal, the rule that appears later wins.

    Specificity is compared as (IDs, classes/attributes/pseudo-classes, elements/pseudo-elements):

    SelectorSpecificity
    p(0, 0, 1)
    .card p(0, 1, 1)
    #main .card p(1, 1, 1)
    inline style=""beats any selector
    !importantoverrides normal declarations; avoid it

    :where() adds zero specificity, while :is() and :not() take the specificity of their most specific argument.

    Keep specificity low and flat (for example single classes with a BEM-style or utility approach) so styles stay easy to override.

    Open full page
  • Why they ask this: Accessibility is increasingly expected; it shows care for all users and code quality.

    Answer

    • Use semantic elements (<button>, <nav>, <main>, headings in order) before reaching for ARIA.
    • Give images meaningful alt text (alt="" for decorative images).
    • Connect every form field to a <label> (for/id, or wrap the input).
    • Make everything usable with the keyboard: a logical tab order and a visible :focus-visible style.
    • Keep enough colour contrast: at least 4.5:1 for normal text (WCAG AA).
    • Use ARIA only to fill gaps, for example aria-expanded on a menu toggle or aria-live for status messages.

    Check your work with Lighthouse or axe DevTools and by navigating with only the keyboard.

    Open full page
123