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

19 questions

12
  • 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: 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: Loose equality causes subtle bugs; interviewers want to see that you default to strict comparison.

    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: A quick fundamentals question that checks attention to detail.

    Answer

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

    Answer

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

    Answer

    Open full page
  • Why they ask this: The most basic React concept; a weak answer is a red flag for any React role.

    Answer

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

    Answer

    Open full page
  • Why they ask this: Layout bugs often come from misunderstanding widths, padding and borders.

    Answer

    Open full page
  • Why they ask this: Checks you can choose the right layout tool instead of fighting CSS.

    Answer

    Open full page
  • Why they ask this: Positioning is needed for dropdowns, modals and sticky headers.

    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.

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

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.

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

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.

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

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>

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.

  • Flexbox is one-dimensional: it lays items out in a row or a column. It is great for navbars, toolbars, centring, and spacing items whose size comes from their content.
  • Grid is two-dimensional: rows and columns together. It is great for page layouts, card galleries and dashboards.
css
/* Flexbox: navbar */
.nav { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }

/* Grid: responsive cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }

They work well together, for example a Grid page layout with Flexbox inside each card.

  • static (default): normal document flow. top/left have no effect.
  • relative: stays in the flow, but can be nudged with top/left. It also becomes the containing block for absolutely positioned children.
  • absolute: removed from the flow and positioned relative to the nearest positioned ancestor (any value other than static), or the initial containing block if there is none.
  • fixed: removed from the flow and positioned relative to the viewport, so it stays put while scrolling. Note that a transform on an ancestor changes this.
  • sticky: acts like relative until a scroll threshold (such as top: 0) is reached, then sticks within its parent.
css
.dropdown-wrapper { position: relative; }
.dropdown-menu { position: absolute; top: 100%; left: 0; }
.site-header { position: sticky; top: 0; }