Senior JavaScript Technical Interview Question | Learn Web Development Now

preview_player
Показать описание
Try to solve the question yourself first!

Learn Web Development NOW!
HTML, CSS, & JavaScript Tutorials

#javascript #interview #tutorial

This video is not to be reproduced without prior authorization.
Рекомендации по теме
Комментарии
Автор

If you want to push your code little bit further you may wanna use async/await feature as well.
```
/*
1. Implement ES6 into the 'john' {}
2. Return value from the 'deduct' () after 2s
*/


const sleep = time => new Promise((resolve) => setTimeout(resolve, time))


var john = {
name: 'John Doe',
balance: 1500,
async deduct(amount) {
await sleep(2000);
this.balance = this.balance - amount;
return '${this.name} has a balance of ${this.balance}';
}
}




```

kamalbennani
Автор

Thanks for the video! I was actually able to solve the problem in my head without looking at the fiddle or looking at any reference. This means I can probably pass senior dev interviews by now. This video helped my confidence. Thanks.

kimnejudne
Автор

It's a normal practice to start with easy stuff like zhe one in this video - just to understand who you are dealing with. One of the real questions I was asked for senior position after simple ones was - implement promise polyfil xD And I was very close, just not enough time to finish it properly (I had just 30 minutes). Try it out (without googling) it's a lot of fun!

bezrodnovAleksey
Автор

Awesome interview problem, as a beginner it's unblock my 'this' keyword problem. Finally I understand very well the concept of this and arrow function utility . Thanks for your video and hope you've many like that

AbouHallassi
Автор

8:02 mins is all you need to understand the best parts of ES6.

suryatejapothureddy
Автор

For the second one If I'm correct you can also save 'this' into a local variable inside that scope that way it will be available for the settimeout function, correct me if I'm wrong I don't have a console to test right now

soykike
Автор

You didn't really explain why you used the Promise and how it solved the problem.

justadev____
Автор

Wouldn't the ES6 way of doing this be using a Class instead?

Christopher_
Автор

If this are the type of interview questions they ask i might be able to work in sillicon valley too, damn

kevin
Автор

Awesome man, very helpful... Promises are really important :)

shubhsagar
Автор

`this` doesn't reference the scope of the function, but it does reference the parent of the object (which is in this case the Window) (You can verify it by console logging this)

kamalbennani
Автор

Was this considered senior-level at the time? These seem like everyday methods and solves.

aaron___
Автор

Hmmmm, it seems the explanation of the last challenge is not true, setTimeout put the execution to call stack but not change its context

xcoolplayz
Автор

Thank you for sharing Jade. I'm wondering if you got the job you interviewed for. Please let us know.

chidinwaka
Автор

I would also convert john into a class

class John {
constructor() {
this.name = 'John Doe';
this.balance = 1500;
}

deduct(amount) {
return new Promise((resolve, reject) => {
this.balance = this.balance - amount;
setTimeout(() => {
resolve(`${this.name} has a balance of ${this.balance}`);
}, 2000)
});
}

}

(async function() {
const johns = new John();
document.body.innerText = await johns.deduct(300);
})();

imfluder
Автор

Hi i can't get one thing what promise exactly doing here?

arunkaiser
Автор

how is this senior developer interview ? it's just syntax testing?

aqua
Автор

I don't believe that was the question for a Senior level position

alexkakhnovskyi
Автор

I guess the task is too easy for senior position

stas
Автор

I'm filing an abuse report for your keyboard..

wescorman