Quiz: Frontend
Frontend questions from real interviews as a quiz, with an explanation for every option.
Try it: 5 questions
Loading…
Sample questions
In what order does a regular DOM click event propagate if it is not stopped?
- Bubble from the root to the target → handlers on the target → capture back to the root
- Capture from the root to the target → handlers on the target → bubble from the target to the root
- Capture from the root to the target → bubble from the target to the root → handlers on the target
- Handlers on the target → capture back to the root → bubble toward the root
What does a conditional type in TypeScript do?
- Declares a type that can contain only values matching both specified types.
- Chooses one of two types based on whether a type satisfies an
extendscondition. - Converts a value at runtime if it matches a type.
- Combines two types into one using the
extendsoperator.
Which practices are appropriate for securely storing and passing secrets for LLMs, databases, and queues in production? Select all that apply.
- Pass secrets to the server process through environment variables, without treating them as a replacement for a secrets manager.
- Pass secrets through frontend build variables if the resulting code is minified and obfuscated.
- Keep secrets in an encrypted repository file and decrypt them in the browser when needed.
- Make LLM calls and access to databases and queues through the backend; restrict permissions, use TLS, rotate secrets, and keep them out of logs.
- Store secrets in a secrets manager and have the backend retrieve them at startup or during runtime.
Which statement about
@StateObjectin SwiftUI is correct?StateObjectrequires an explicit type even when its initial value already specifies a concrete model.StateObjectis an ordinary type that determines the model automatically from the property name.StateObjectis a generic type; its model type must conform toObservableObjectand can be inferred from the initial value.StateObjectcan store an object of any type because it checks the object only at runtime.
How does short polling work: who initiates requests, and what does the server do in response?
- The client requests data once, and the server regularly sends updates in the response.
- The client sends HTTP requests periodically, and the server immediately returns the data currently available.
- The server sends updates to the client over a persistent connection.
- The client opens a request and waits for the server to send an update or for a timeout.
Select all correct recommendations for
keyin React lists.- If there is no
id, generate a new randomkeyon every render. - Prefer a unique, stable identifier for each record.
- An array index remains reliable after insertions and reordering because React updates it automatically.
- If there is no
id, you can create a key once when loading the data and store it with the record. keyhelps React match elements between renders.
- If there is no
What is characteristic of a JavaScript expression?
- It always controls the program's execution flow.
- It is evaluated to produce a value.
- It always consists of a function call.
- It always declares a new variable.
Which statements about storing refresh tokens on the server are correct? Select all that apply.
- If you store a token, it is better to keep its hash and metadata rather than the original value.
- Every refresh token must be stored in a database, even when the application uses stateless JWTs.
- To make revocation possible, the token must be stored in the database in plaintext.
- Refresh-token rotation helps detect reuse of an old token, and the whole token family can then be revoked.
- A session or token record is useful when you need to revoke individual sessions or detect token reuse.
What behavior should
memo(fn)provide when applied tosum?- Return a wrapper that caches results by arguments and reuses them when the same arguments recur.
- Store the call arguments but recompute the result each time.
- Modify
fnto remember only the result of its most recent call, regardless of the arguments. - Run
fnon every call, then store its result to compare with future calls.
How do ordinary curly braces affect scope in JavaScript?
- A standalone block scopes
let,const, andclass; it does not scopevar. - A standalone block scopes
var, whileletandconstremain visible outside it. - Any curly braces create a scope for every declaration inside them.
- Curly braces create scope only for
vardeclarations.
- A standalone block scopes