const { foo: [bar], bar: [{ baz: foo }] } = { foo: [1], bar: [{ baz: 3 }] } console.log(bar) console.log(foo) //
Frontend
Render va chizish o'rtasidagi farq nima? Virtual va haqiqiy DOM daraxtini taqqoslash jarayoni nima deb ataladi?
const SomeElement = ({ hasData }) => { if (hasData) { return <div> <DataElement /> <SomeImportantElement /> </div> } return <div> <SomeImportantElement /> </div> }
const { foo: bar, bar: foo } = { foo: 1, bar: 2 }; //foo //bar setTimeout(() => { console.log("timeOut"); }, 0); console.log(1); new Promise((resolve) => { console.log("Promise"); setTimeout(() => { console.log("timeOut2"); resolve(); }, 0); }) .then(() => { console.log("then1"); }) .then(() => { console.log("then2"); }); console.log(4); setTimeout(() => { console.log("timeOut3"); }, 0);
Ko'rib chiqish uchun kod oldingiz — bu yerda nima optimallashtirilmagan?
JavaScriptda yopilish nima? Amalda qaerda ishlatiladi?
import React, { useState, useEffect, useRef, useContext, useReducer, useMemo, me 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}> Арттир </button> <ul> {arr.map((n, index) => <li key={index}>{n}</li>)} </ul> </> ) } export default () => <LazyInit arr={[1, 2, 3]} />;
Bir soniya ichida hal qilinadigan Promise qaytaradigan funksiyani qanday yozish mumkin?
// findUnique usuli arrayga qo'llaniladi va yangi arrayni, faqat unikal elementlar bilan, // ya'ni asl arrayda faqat bir marta mavjud bo'lgan elementlar bilan, bir xil tartibda, qaytaradi. // findUnique metodini implement qilish kerak, shunda u oddiy array metodidek ishlaydi [10, 5, 10, 1, 6, 6, 7, 9, 9, 10].findUnique(); // [5, 1, 7]
useEffect'da bog'liq bo'laklar ro'yxatini ko'rsatmasangiz nima bo'ladi? Agar bog'liq bo'laklar ro'yxatiga count qo'shsangiz va tugmani bosilsa, cleanup-funksiyasi ishga tushadimi?
Event Loop nima ekanligini tushuntiring. Mikrotasiyalar va makrotasiyalar qaysilar?
Event Loop haqida gapir: u qanday ishlaydi, mikro vazifalar va makro vazifalar nima?
const createCounter = () => {
Yopiq misol keltiring. Reactda yopiqdan foydalaningiz bormi?
TypeScript'da unknown turi nima uchun kerak? Turi qanday toraytiriladi?
const a = {} a[1] = 'test' for ( ... )
setTimeout(() => { console.log("timeOut"); }, 0) console.log(1); new Promise(resolve => { console.log("Promise"); setTimeout(() => { console.log("777"); resolve() }, 0) }).then(() => { console.log("then1"); }) .then(console.log('tratata')) .then(() => console.log("then2"); }) console.log(4); setTimeout(() => { console.log("timeOut2"); }, 0)
const doSomething = (ms) => { return new Promise((resolve, reject) => { setTimeout(() => { if (Math.random() <= 0.5) { reject("error"); } else { resolve(ms); } }, ms); }); }; const getDelay = () => { let rand = 1000 + Math.random() * 2000; return Math.floor(rand); }; const p1 = doSomething(getDelay()); const p2 = doSomething(getDelay()); const p3 = doSomething(getDelay()); const p4 = doSomething(getDelay());
Cookie'larning qanday sozlamalari mavjud (httpOnly, secure, expires, domain, path)?
sessionStorage va localStorage o'rtasidagi farq nima?