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

25 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 (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.

    Open full page
  • Why they ask this: Checks that you understand what React does for you rather than only using its syntax.

    Answer

    The virtual DOM is a lightweight JavaScript description of the UI (React elements). When state or props change:

    1. React re-renders the affected components, producing a new element tree.
    2. It compares the new tree with the previous one. This is called reconciliation or diffing.
    3. It applies only the minimal real DOM changes needed in the commit phase.

    Diffing rules worth knowing:

    • Elements of a different type (<div> vs <span>, or different components) are replaced entirely.
    • In lists, key tells React which item is which, so it can reuse and move elements correctly.

    Touching the real DOM is the slow part, so batching updates and changing only what differs keeps the UI fast and lets you write declarative code.

    Open full page
  • Why they ask this: The starting point for any Laravel interview; it shows you know where code belongs.

    Answer

    MVC (Model–View–Controller) separates an application into three parts:

    • Model: data and business rules. In Laravel these are Eloquent models (app/Models), each mapped to a database table.
    • View: what the user sees. In Laravel these are Blade templates (resources/views), or JSON from API Resources in an API.
    • Controller: receives the request, calls models or services, and returns a response (app/Http/Controllers).

    The flow: route (routes/web.php or routes/api.php) → middleware → controller → model → view or JSON response.

    php
    Route::get('/jobs/{job}', [JobController::class, 'show']);
    
    class JobController extends Controller
    {
        public function show(Job $job) // route model binding
        {
            return view('jobs.show', ['job' => $job]);
        }
    }

    In bigger apps, keep controllers thin and move business logic into service or action classes.

    Open full page
  • Why they ask this: Joining tables is daily backend work and a staple of online tests in Nepal.

    Answer

    • INNER JOIN: only rows that match in both tables.
    • LEFT JOIN: all rows from the left table, plus matches from the right. Missing matches come back as NULL.
    • RIGHT JOIN: the mirror of LEFT JOIN.
    • FULL OUTER JOIN: all rows from both tables. MySQL does not support it directly; combine a LEFT and a RIGHT JOIN with UNION.
    • CROSS JOIN: every combination of rows (a Cartesian product).
    • SELF JOIN: a table joined to itself, for example employees and their managers.
    sql
    -- Every company, with its job count (including companies with no jobs)
    SELECT c.name, COUNT(j.id) AS jobs
    FROM companies c
    LEFT JOIN jobs j ON j.company_id = c.id
    GROUP BY c.id, c.name;

    Note that COUNT(j.id) counts only matched rows, while COUNT(*) would count 1 for a company with no jobs.

    Open full page
  • Why they ask this: Loose equality causes subtle bugs; interviewers want to see that you default to strict comparison.

    Answer

    • === (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.

    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

    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.

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

    Answer

    • 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'.

    Open full page
  • Why they ask this: Hooks are how modern React is written; breaking the rules causes hard-to-find bugs.

    Answer

    Hooks are functions that let function components use React features: useState (state), useEffect (side effects), useContext, useRef, useMemo, useCallback, and your own custom hooks (useSomething).

    Rules of hooks:

    1. Call hooks only at the top level of a component or custom hook, never inside conditions, loops or nested functions. React identifies each hook by its call order.
    2. Call hooks only from React function components or custom hooks, not from regular functions.
    jsx
    function Profile({ userId }) {
      const [user, setUser] = useState(null);       // top level: OK
      // if (userId) { useEffect(...) }             // wrong: conditional hook
      useEffect(() => {
        if (!userId) return;                         // put the condition inside
        fetch(`/api/users/${userId}`).then((r) => r.json()).then(setUser);
      }, [userId]);
      return <p>{user?.name}</p>;
    }

    The eslint-plugin-react-hooks lint rules catch most mistakes.

    Open full page
  • Why they ask this: Wrong keys cause subtle UI bugs, so this checks practical experience.

    Answer

    A key gives each list item a stable identity, so React can tell which items were added, removed or reordered between renders and keep the right state and DOM node for each one.

    jsx
    {todos.map((todo) => (
      <TodoItem key={todo.id} todo={todo} />
    ))}
    • Use a stable, unique id from your data.
    • Avoid the array index as a key when items can be inserted, deleted or reordered. React would then match state (such as an input's text) to the wrong item.
    • Keys only need to be unique among siblings.
    Open full page
  • Why they ask this: The most basic React concept; a weak answer is a red flag for any React role.

    Answer

    PropsState
    Owned bythe parentthe component itself
    Changeable by the component?No, read-onlyYes, through the setter (setX)
    Purposeconfigure a component and pass data downdata that changes over time
    jsx
    function Counter({ step }) {          // step is a prop
      const [count, setCount] = useState(0); // count is state
      return <button onClick={() => setCount((c) => c + step)}>{count}</button>;
    }

    Changing either one re-renders the component. When two siblings need the same data, lift the state up to their common parent and pass it down as props.

    Open full page
  • Why they ask this: Shows you care about accessibility and SEO, not only how a page looks.

    Answer

    Semantic HTML uses elements that describe their meaning, not only their appearance: <header>, <nav>, <main>, <article>, <section>, <aside>, <footer>, <button>, <label>, and headings <h1>–<h6> in order.

    Why it matters:

    • Accessibility: screen readers use these landmarks and roles to navigate. A <button> is keyboard-focusable and clickable with Enter or Space by default; a clickable <div> is not.
    • SEO: search engines understand the page structure better.
    • Maintainability: the markup is easier for other developers to read.
    html
    <main>
      <article>
        <h1>Frontend Developer at Kathmandu Tech</h1>
        <p>...</p>
        <button type="button">Apply now</button>
      </article>
    </main>
    Open full page
  • Why they ask this: Layout bugs often come from misunderstanding widths, padding and borders.

    Answer

    Every element is a box made of four layers, from inside out: content → padding → border → margin.

    • With the default box-sizing: content-box, width sets only the content. Padding and border are added on top, so width: 200px; padding: 20px; border: 1px renders 242px wide.
    • With box-sizing: border-box, width includes padding and border, so the element stays 200px wide. This is far easier to reason about.
    css
    *, *::before, *::after {
      box-sizing: border-box;
    }

    Margins are outside the box and can collapse: vertical margins of adjacent block elements combine into the larger of the two instead of adding up.

    Open full page
123