Student id: 4160 Necha turdagi execution context mavjud va ular qaysilar?


Download 17.47 Kb.
Sana17.10.2023
Hajmi17.47 Kb.
#1705527
Bog'liq
1-oy imtixon


STUDENT ID: ____4160_______

  1. Necha turdagi execution context mavjud va ular qaysilar?

    1. 2 turdagi local va tashqi

    2. 2 turdagi global va local

    3. 2 turdagi global va funksiya

Javobi C

  1. Quidagi misolda loglar qay tartibda chiqadi? console.log(“foo”); setTimeout(() => { console.log(“bar”);

}, 0); console.log(“baz”);

    1. foo -> baz -> bar

    2. foo -> bar -> baz

    3. foo -> baz

-> bar
Javobi C

  1. 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”____________

  1. 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); ______________________

  1. 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();

    1. 10 -> 11

    2. 10 -> 10

    3. TypeError Line 5

Javob C chunki bind bir marta ishleydi

  1. OOPda enkapsulasi nima?
    qobiqlashtrish function va ozgaruvchilarni bitta joyda saqlash

______________________________________________________________________

  1. OOPda inheritance nima?

____________________________avlod olish__________________________________________ 8. OOPda abstraction nima?
_______________________________________________________mavhumlik______________

  1. OOPda poliformizm nima?

______________________________________________________________________

  1. Node.jsda necha turdagi modulelar mavjud?

________________________________________3 turdagi______________________________

  1. fs kutobxonasi necha turdagi apilar beradi

    1. promise, callback, sinxron

    2. bufferli va streamli

Javob A

  1. Quidagi misolni promise bilan yozing

fs.readFile(‘./example.txt’, (err, file) => { if(err) { console.log(‘Error’, err); return;
} console.log(file);
})

javobi
const fs = require('fs');


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’);

    1. bar -> bar

    2. bar

    3. bar -> Error is thrown

javobi C chunki once bir marta ishlaydi

  1. Node.jsga Buffer nima uchun kerak?

  2. 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