Domanda di colloquio di PayPal

Explain this: var Bob = { name: "Bob", name_fn: function(){ return this.name; } } console.log(Bob.name_fn()) //"Bob" var fn = Bob.name_fn console.log(fn()) //undefined

Risposte di colloquio

Anonimo

29 mar 2016

when you call fn() its scope is in global. The function call should be scoped properly to work. You should use call or apply to make it work.

2

Anonimo

15 dic 2020

It's essential to demonstrate that you can really go deep... there are plenty of followup questions and (sometimes tangential) angles to explore. There's a lot of Software Engineer III experts who've worked at PayPal, who provide this sort of practice through mock interviews. There's a whole list of them curated on Prepfully. prepfully.com/practice-interviews

Anonimo

22 set 2015

fn is "Bob" and not a method.