Sobes.tech

Write a function getUserProfile that takes a userId as an argument and fetches the user profile from the API endpoint "[link] The function should log the user profile if the fetch is successful, and log an error message if the fetch fails.

Middle+
132

What static methods of Promise do you know? Tell about them.

Middle+
132

import React, { useState, useEffect, useLayoutEffect } from 'react'; export default () => { const [count, setCount] = useState(0); useLayoutEffect(() => console.log("each render 1")); console.log("each render 2"); useEffect(() => console.log("each render 3")); return ( <button onClick={() => setCount((prevProps) => ++prevProps)}> Increment </button> ); } // mount -> each render 2, each render 1, each render 3 // update -> each render 2, each render 1, each render 3 // unmount 4

Middle+
131

What is a Set? What can we pass when calling new Set as an argument?

Middle+
131

Do let and const (hoisting) pop up? What happens when you access them before declaration?

Middle+
129

const S = { id: 1, name: "Ivan", age: "39", tel: [phone] }; function getParam(obj, key) { return obj[key]; } getParam(S, "tel"); getParam(S, "job");

Middle+
129

Write an abstract implementation of a Child component with memoization using React.memo. What is the second argument that React.memo accepts?

Middle+
128

Write what will happen during the first render — in what order will console.logs appear? What happens after clicking?

Middle+
127

What is WeakSet?

Middle+
126

import React, { useState, useEffect, useRef, useContext, useReducer, useMemo } from 'react'; const someFunc = (arr) => { return [...arr].sort((a, b) => a - b); }; const LazyInit = (props) => { const [arr, setArr] = useState(() => someFunc(props.arr)); const onClick = () => { setArr((prev) => prev.concat(prev.length + 1)) } return ( <> <button onClick={onClick}> Increment </button> <ul> {arr.map((n, index) => <li key={index}>{n}</li>)} </ul> </> ) } export default () => <LazyInit arr={[1, 2, 3]} />; --- The conversation on the right side discusses: - Using TypeScript with generics: "<T extends object, K extends keyof T>" - Checking if data is a string with a type guard: "isString(data: unknown): data is string { ... }" - Using useState with a function to avoid re-running on every render: ``` const [state, setState] = useState(getComplexData); // or const [state, setState] = useState(() => getComplexData()); ``` - The function passed to useState will run only once on component mount. - Warning about mutating state directly on line 11 with prev.concat. --- The technical task is to analyze and possibly fix or optimize the React component code, especially focusing on: - Proper lazy initialization of state with useState. - Avoiding direct mutation of state. - Understanding TypeScript generics and type guards. - Ensuring the component updates state correctly on button click.

Middle+
124

What is a closure?

Middle+
122

There are three data sources returning the same information. How to get the response from the fastest one?

Middle+
119

What is the difference between Map and WeakMap?

Middle+
118

If you refer to the arguments argument in an arrow function, what will be there?

Middle+
113

Tell me about the useState hook in React.

Middle+
111

How are functions created in JavaScript? What are the ways to create functions and how do they differ?

Middle+
105

Why can't arrow functions be used with the new constructor?

Middle+
103

What utility types of TypeScript do you use in your work? Tell me about Record, Pick, Omit, Partial, Required, Parameters, Exclude, Extract.

Middle+
97
/5
Questions for Frontend preparation — Page 5 - sobes.tech