и посмотреть медиа
Frontend | Interview questions
и посмотреть медиа
Interview questions frontend randomly.
Interview questions frontend randomly.
AI bot for text-to-speech and voice cloning in Telegram. Create audio using neural network quickly and easily.
Collection of frontend questions: JavaScript, frameworks, performance, accessibility. Detailed answers will help confidently pass interviews.
🤔 Что делает omit? omit – это функция, которая удаляет указанные ключи из объекта и возвращает новый объект без этих ключей. В JavaScript нет встроенного omit, но его можно реализовать с помощью деструктуризации и методов Object.fromEntries() или reduce(). Реализация omit с Object.fromEntries() (современный способ) function omit(obj, keys) { return Object.fromEntries( Object.entries(obj).filter(([key]) => !keys.includes(key)) ); } const user = { name: "Alice", age: 25, password: "123456" }; const safeUser = omit(user, ["password"]); console.log(safeUser); // { name: "Alice", age: 25 } Реализация omit с reduce() (альтернативный способ) function omit(obj, keys) { return Object.keys(obj).reduce((acc, key) => { if (!keys.includes(key)) acc[key] = obj[key]; return acc; }, {}); } const data = { a: 1, b: 2, c: 3 }; console.log(omit(data, ["b"])); // { a: 1, c: 3 } Если используете Lodash, можно просто вызвать import { omit } from "lodash"; const user = { name: "Alice", age: 25, password: "123456" }; const safeUser = omit(user, ["password"]); console.log(safeUser); // { name: "Alice", age: 25 } Ставь 👍 и забирай 📚 Базу знаний
Открыть канал и посмотреть медиаOnly registered users can share their opinion.
Be the first to share your impression of this resource!