Sobes.tech

What does the 'in' operator do in TypeScript?

Middle+
182

Tell about useCallback — use case, why is it needed?

Middle+
181

Tell about working with forms in React: controlled and uncontrolled components, pros and cons of each approach.

Middle+
178

const LiveSearch = () => { const [inputValue, setInputValue] = useState('') const onInputChange = (e) => { setInputValue(e.target.value) search(e.target.value) } return ( <div> <input value={inputValue} onChange={onInputChange} type="text" /> </div> ) } <span> Searching for: <LiveSearch /> </span>

Middle+
174

// Data about the price of a product received from the server as a number: // 12345678 (the price can be any but in the range from 1 to [phone]) // need to write a function that converts the price to a formatted string like: // 12'345'678

Middle+
174

Task: traverse a tree of objects (each object has fields value and elements) and calculate the sum of all values. How would you implement this?

Middle+
173

Have you worked with Blob? How to create a download link for a dynamically generated file?

Middle+
172

const X = { a: 1, b: 2, c: 3, d: 4 } function getProperty(obj, key) { // Task to type the function return obj[key] } getProperty(X, 'a') // no error getProperty(X, ' ') // error: key is not a valid key for object X getProperty({ name: 'Sergey' }, 'name') // no error

Middle+
172

Tell us about the stages of the React component lifecycle.

Middle+
172

Are there other methods of automatic memory management besides G1 Garbage Collector?

Middle+
170

function sum(a, b) { return a + b; } function memo() {}

Middle+
168

let x = 5; (function () { console.log(x); let x = 0; })()

Middle+
166

import React, { useState, useEffect, useRef, useContext, useReducer, useMemo } 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 () => { console.log(4); }; }, [count]); return ( <button onClick={() => setCount((prevProps) => ++prevProps)}> Increment </button> ); }

Middle+
166

What is the cleanup function in useEffect? When does it run? Write it in useEffect.

Middle+
166

How to implement tree traversal without recursion? What data structure can help?

Middle+
165

const { foo: [bar], bar: [{ baz: foo }] } = { foo: [1], bar: [{ baz: 3 }] } console.log(bar) console.log(foo) //

Middle+
165

Tell me about Virtual DOM and the reconciliation mechanism in React. How does React optimize tree comparison?

Middle+
164

How to write a function that returns a Promise resolving after one second?

Middle+
163

What happens if the component type changes? Will the same key help preserve the state?

Middle+
163

const SomeElement = ({ hasData }) => { if (hasData) { return <div> <DataElement /> <SomeImportantElement /> </div> } return <div> <SomeImportantElement /> </div> }

Middle+
162
/5