Student id: 4160 Necha turdagi execution context mavjud va ular qaysilar?
Download 17.47 Kb.
|
1-oy imtixon
STUDENT ID: ____4160_______ Necha turdagi execution context mavjud va ular qaysilar? 2 turdagi local va tashqi 2 turdagi global va local 2 turdagi global va funksiya Javobi C Quidagi misolda loglar qay tartibda chiqadi? console.log(“foo”); setTimeout(() => { console.log(“bar”); }, 0); console.log(“baz”); foo -> baz -> bar foo -> bar -> baz foo -> baz -> bar Javobi C Quidagi misolda loglar qay tartibda chiqadi? function a() { setTimeout(() => c(), 0); console.log(“foo”); } function b() { setTimeout(() => { console.log(“baz”); }, 300) } function c() { b(); setTimeout(() => { console.log(“bar”); }, 500) } a(); ______”foo”,”baz”,”bar”,”bar”____________ sum funksiyasini call methodi bilan chaqiring? function sum(arr) { return arr.reduce((prev, curr) => prev + curr,0) } const arr = [1, 2, 3, 4]; const sumWithApply = sum.apply({},[arr]); const sumWithCall = __= sum.call({},arr); ______________________ Quidagi misol nima natija beradi? function foo() { console.log(this.a); } const baz = foo.bind({ a: 10 }); const bar = baz.bind({ a: 11 }); baz(); bar(); 10 -> 11 10 -> 10 TypeError Line 5 Javob C chunki bind bir marta ishleydi OOPda enkapsulasi nima? qobiqlashtrish function va ozgaruvchilarni bitta joyda saqlash ______________________________________________________________________ OOPda inheritance nima? ____________________________avlod olish__________________________________________ 8. OOPda abstraction nima? _______________________________________________________mavhumlik______________ OOPda poliformizm nima? ______________________________________________________________________ Node.jsda necha turdagi modulelar mavjud? ________________________________________3 turdagi______________________________ fs kutobxonasi necha turdagi apilar beradi promise, callback, sinxron bufferli va streamli Javob A Quidagi misolni promise bilan yozing fs.readFile(‘./example.txt’, (err, file) => { if(err) { console.log(‘Error’, err); return; } console.log(file); }) javobi
const readFilePromise = (filePath) => { return new Promise((resolve, reject) => { fs.readFile(filePath, (err, data) => { if (err) { reject(err); } else { resolve(data); } }); }); }; readFilePromise('./example.txt') .then((data) => { console.log(data); }) .catch((err) => { console.log('Error', err); }); Consolega nima natija chiqadi? const e = new EventEmitter(); e.once(‘bar’, () => { console.log(‘bar’); }) e.emit(‘bar’); e.emit(‘bar’); bar -> bar bar bar -> Error is thrown javobi C chunki once bir marta ishlaydi Node.jsga Buffer nima uchun kerak? Streamlar nima uchun kerak?katta malumotlarni bollaklab uzatish uchun Download 17.47 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling