PayPal Interview Question

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

Interview Answers

Anonymous

Mar 29, 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

Anonymous

Dec 15, 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

Anonymous

Sep 22, 2015

fn is "Bob" and not a method.