تدرب على 60 سؤالًا أصليًا لمقابلات الواجهة الأمامية تغطي JavaScript وHTML وCSS وReact والمتصفح والأداء وإمكانية الوصول والأمان.
المستوى: Frontend Interviewالصعوبة: intermediate60 سؤال60 دقيقة
اختر وضع التدريب وأجب عن كل سؤال ثم راجع الشرح. تُحفظ الأخطاء محليًا.
أيام متتالية: 0 أياممحفوظ على هذا الجهاز فقط
التقدم0 / 60
الوقت المتبقي: 00:00
لا توجد أخطاء محفوظة بعد.
لا توجد أسئلة تطابق عوامل التصفية.
سؤال 1
What is a JavaScript closure?
A closure is created when a function keeps access to variables from its outer scope even after the outer function returns. It enables data privacy and functional patterns.
سؤال 2
What is hoisting in JavaScript?
Hoisting moves variable and function declarations to the top of their scope before execution. `let` and `const` are hoisted but not initialized, so they are not accessible before their declaration.
سؤال 3
What is the difference between == and ===?
The loose equality operator == converts operands to a common type, while === requires the same type and value. Strict equality avoids surprising coercions.
سؤال 4
What is a Promise?
A Promise represents a value that may be available now, later, or never, and supports .then, .catch, and .finally. It is not a loop, event, or animation.
سؤال 5
What does async/await do?
async/await is syntactic sugar over Promises that lets developers write asynchronous code more readably. It does not create workers, block the loop by design, or convert CSS.
سؤال 6
What is event delegation?
Event delegation uses bubbling to handle events from many children with one parent listener. It improves performance and works for dynamically added elements.
سؤال 7
What does `this` refer to in JavaScript?
The value of `this` depends on how a function is called: method call, function call, arrow function, or explicit binding. It is not always global or a DOM element.
سؤال 8
What is a pure function?
A pure function always returns the same result for the same arguments and does not modify external state. It is easier to test and reason about.
سؤال 9
What is immutability?
Immutable data is not modified after creation; updates create new values instead. This reduces bugs and helps predictable UI updates.
سؤال 10
Which array method creates a new array by transforming each element?
.map() returns a new array with each element transformed. .filter() keeps matching elements, .reduce() accumulates a value, and .find() returns the first match.
سؤال 11
Which array method returns elements that match a condition?
.filter() returns a new array with elements that pass a condition. .map() transforms, .push() adds an item, and .sort() orders elements.
سؤال 12
Which array method reduces an array to a single value?
.reduce() applies a reducer function to accumulate a single result. .join() creates a string, .slice() copies a portion, and .concat() combines arrays.
سؤال 13
What is a Set in JavaScript?
A Set stores unique values and ignores duplicates. It is not sorted by default, not a key-value object, and not a tree.
سؤال 14
What is localStorage?
localStorage stores key-value data in the browser and persists across sessions. It is not server-side, a CSS property, or a React hook.
سؤال 15
What is semantic HTML?
Semantic HTML uses meaningful elements that describe structure and content, improving accessibility and SEO. Divs and spans are generic and should be used when no semantic element fits.
سؤال 16
Which landmark element represents the main content of a page?
<main> is a landmark for the primary content of a page. <section> groups related content, and div and span are generic containers.
سؤال 17
What is CSS specificity?
Specificity determines which CSS rule applies when selectors conflict. IDs have higher specificity than classes, and classes have higher specificity than elements.
سؤال 18
In the CSS box model, which property sits between padding and margin?
The box model order is content, padding, border, and margin. The border sits between padding and margin; outline is drawn outside the border.
سؤال 19
What is flexbox designed for?
Flexbox handles one-dimensional layout along a main axis, while CSS Grid handles two-dimensional row and column layout. It is not for print or databases.
سؤال 20
What is CSS Grid designed for?
CSS Grid creates two-dimensional layouts by defining rows and columns together. Flexbox is better for one-dimensional layouts, and grid is not for text or timing.
سؤال 21
Which CSS unit is relative to the root font size?
rem is relative to the root html font size, while em is relative to the parent font size. px is absolute and vh is relative to viewport height.
سؤال 22
Which CSS unit is relative to viewport width?
vw equals 1% of viewport width, and vh equals 1% of viewport height. rem is root-relative and ch is character width.
سؤال 23
What does a media query do?
Media queries apply CSS conditionally, usually based on screen size, orientation, or capabilities. They do not connect databases, load fonts, or handle events.
سؤال 24
What does position: fixed do?
position: fixed places an element relative to the viewport so it stays in place while scrolling. Absolute positions relative to an ancestor, and static/relative follow normal flow.
سؤال 25
What is a pseudo-class?
Pseudo-classes select states or positions, such as :hover, :focus, and :first-child. They are not generated classes, variables, or attributes.
سؤال 26
What does box-sizing: border-box do?
box-sizing: border-box makes width and height include content, padding, and border, which simplifies sizing. It does not remove borders, center, or create grids.
سؤال 27
What is a React component?
A React component is a reusable function or class that renders UI. It is not a CSS class, event, or database table.
سؤال 28
What are props in React?
Props are read-only inputs passed from parent to child components. State is managed inside a component, and props are not DOM nodes or globals.
سؤال 29
What is state in React?
State is component-owned data that can change and trigger re-renders. Props are passed in from parents; state is not a cache or stylesheet.
سؤال 30
What is a React hook?
Hooks such as useState and useEffect let function components use React features. They are not animations, APIs, or selectors.
سؤال 31
Which hook manages state in a function component?
useState returns a state value and its setter. useEffect runs side effects, useRef holds mutable references, and useReducer manages complex state with reducers.
سؤال 32
Which hook runs side effects after render?
useEffect runs side effects such as data fetching or subscriptions after render. useState manages values, useMemo memoizes computations, and useContext reads context.
سؤال 33
What is the virtual DOM?
React keeps a virtual DOM in memory, diffs changes, and updates the real DOM efficiently. It is not the real DOM, a template, or a CSS layer.
سؤال 34
Why do list items need keys in React?
Keys give list items stable identities so React can reconcile changes efficiently. They are not for styling, events, or storage.
سؤال 35
What is a controlled input in React?
A controlled input derives its value from state and updates state on change. Uncontrolled inputs manage their own value in the DOM.
سؤال 36
What is reconciliation in React?
Reconciliation is how React compares the previous and next virtual DOM and applies minimal real DOM updates. It is not database merging, CSS compiling, or bundling.
سؤال 37
What does useMemo do?
useMemo caches the result of a computation until dependencies change. useRef creates mutable refs, useEffect runs effects, and useState manages state.
سؤال 38
What is the DOM?
The Document Object Model represents HTML as a tree of nodes that scripts can read and modify. It is not a database, preprocessor, or protocol.
سؤال 39
Which method selects an element by its id?
document.getElementById() returns the element with a matching id. querySelectorAll returns multiple matches, createElement creates nodes, and fetch makes network requests.
سؤال 40
Which method attaches an event listener?
addEventListener() registers a handler for an event. setTimeout delays code, appendChild adds nodes, and getAttribute reads attributes.
سؤال 41
What is event bubbling?
Bubbling means an event on a target also triggers handlers on its ancestors. The capture phase travels from the root down to the target.
سؤال 42
What is the event loop?
The event loop manages the call stack, task queue, and microtask queue so asynchronous callbacks run at the right time. It is not DOM, CSS, or network logic.
سؤال 43
What is a microtask?
Microtasks, including promise callbacks, run after the current task and before the next task. They are not workers, long functions, or cookies.
سؤال 44
What is requestAnimationFrame used for?
requestAnimationFrame schedules a callback before the next repaint for smooth animations. It is not for network requests, debouncing, or measuring.
سؤال 45
What is a cookie?
Cookies are small pieces of data that browsers store and send to servers with requests, often for sessions and tracking. They are not variables, units, or hooks.
سؤال 46
What does stopPropagation do?
stopPropagation prevents the event from continuing to bubble or capture. preventDefault stops the default action such as form submission or navigation.
سؤال 47
What is debouncing?
Debouncing waits for a quiet period before calling a function, useful for search inputs. Throttling limits calls to once per interval, which is different.
سؤال 48
What is throttling?
Throttling ensures a function runs at most once per interval, useful for scroll or resize handlers. Debouncing waits for a pause instead.
سؤال 49
What is lazy loading?
Lazy loading defers images, scripts, or routes until needed, reducing initial load. It is not about network speed or API caching.
سؤال 50
What are Core Web Vitals?
Core Web Vitals measure loading, interactivity, and visual stability with metrics such as LCP, INP, and CLS. They are not database, network, or ad metrics.
سؤال 51
Which Core Web Vital measures visual stability?
Cumulative Layout Shift (CLS) measures unexpected layout shifts. LCP measures loading, INP measures interactivity, and TTFB measures server response.
سؤال 52
Which Core Web Vital measures loading performance?
Largest Contentful Paint (LCP) measures when the main content becomes visible. CLS measures layout stability, and INP/FID measure interactivity.
سؤال 53
What is ARIA?
ARIA attributes communicate roles, states, and properties to assistive technology. They are not a framework, library, or extension.
سؤال 54
What is XSS?
Cross-site scripting injects malicious scripts into trusted pages, often through unescaped user input. It is not CSS, caching, or a React error.
سؤال 55
What is a Content Security Policy?
CSP is a security header that restricts scripts, styles, and other resources to reduce XSS risk. It is not a cookie, database, or CSS rule.
سؤال 56
What is CORS?
CORS lets servers declare which origins may access their resources through browser headers. It is not CSS, a framework, or a DOM method.
سؤال 57
Which of the following are JavaScript array methods? Select all that apply.
.map(), .filter(), and .reduce() are JavaScript array methods. .append() is a DOM method, not an array method.
سؤال 58
Which of the following are React hooks? Select all that apply.
useState, useEffect, and useMemo are React hooks. useDOM is not a built-in React hook.
سؤال 59
Flexbox is the best choice for two-dimensional grid layouts.
Flexbox is best for one-dimensional layouts. CSS Grid is designed for two-dimensional row and column layouts, so the statement is false.
سؤال 60
Match each CSS unit to its meaning.
rem is root-relative, vw is viewport width, vh is viewport height, and percent is relative to the parent.