NextIva Round 1 for Lead React Developer position
const p1 = Promise.resolve(1);
const p2 = Promise.reject('Error!');
const p3 = Promise.resolve(3);
// Promise.all([p1, p2, p3])
// .then((result) =>console.log('All:', result))
// .catch((error) =>console.log('Caught:', error));
// Promise.allSettled([p1, p2, p3])
// .then((result) =>console.log('All Settled:', result));
// all - Caught: Error!
// allSettled - 'All Settled: [1, 'Error!', 3]'
// console.log('Start');
// setTimeout(() => console.log('Timeout 1'), 0);
// Promise.resolve().then(() => console.log('Promise 1'));
// Promise.resolve().then(() => {
// console.log('Promise 2');
// setTimeout(() => console.log('Timeout 2'), 0)
// });
// console.log('End');
// () => console.log('Timeout 1')
// console.log('Promise 1')
//console.log('Promise 2');
// -> setTimeout(() => console.log('Timeout 2'), 0);
/*
Start
End
Promise 1
Promise 2
Timeout 1
Timeout 2
*/
const obj = { a: 1 };
Object.defineProperty(obj, 'b', {
value: 2,
writable: false,
enumerable: false, // wont come inside object.keys
configurable: false, // cant be deleted
});
obj.b = 3;
console.log(obj.b);
console.log(Object.keys(obj));
delete obj.b;
console.log(obj.b)
/*
2
[a, b]
undefined
*/
const promise1 = Promise.resolve(1);
const promise2 = new Promise((resolve, reject) => setTimeout(reject, 100, 'Error'));
const promise3 = new Promise((resolve) => setTimeout(resolve, 50, 3));
Promise.all([promise1, promise2, promise3])
.then((results) => {
console.log('Results:', results);
})
.catch((error) => { console.log('Caught:', error); });
// Caught: Error
// proxies in javascript
// event delegation in javascript
// how to secure routes/api in react app from unauthorized access
// how to improve data fetching in react app
// how redux achieve immutability
// limitation of HOCs
// how to ensure smooth communication among team mates
// how to discuss prioritized tasks with the product/management team
Comments
Post a Comment