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

63 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: 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: 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: 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: 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: 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: The first concept of every Flutter app; it shows you understand how the UI rebuilds.

    Answer

    • A StatelessWidget has no mutable state. Its build() output depends only on its constructor arguments (and inherited data such as the theme). Examples: a label or an icon button.
    • A StatefulWidget has a separate State object that lives across rebuilds. Calling setState() marks it dirty so build() runs again. Examples: a form, a counter, a tab view.
    text
    class Counter extends StatefulWidget {
      const Counter({super.key});
    
      @override
      State<Counter> createState() => _CounterState();
    }
    
    class _CounterState extends State<Counter> {
      int count = 0;
    
      @override
      Widget build(BuildContext context) {
        return TextButton(
          onPressed: () => setState(() => count++),
          child: Text('Tapped $count times'),
        );
      }
    }

    Use the State lifecycle methods: initState() for setup and dispose() to release controllers, streams and timers.

    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: 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: 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: 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
12345