KEY NOT FOUND: coverImgAlt
Logo
See All Photos

Bloomberg L.P.

Engaged Employer

Bloomberg L.P.

Add an Interview

Interview Question

Front End Web Developer Interview

-

Bloomberg L.P.

What is a JavaScript callback function?

AnswerAdd Tags

Interview Answers

5 Answers

8

A callback function is a piece of JavaScript code that executes after the main function that the callback is attached to executes successfully.

Anonymous on

1

udaykanth, I would say that a .forEach() would be the most common and most basic use of a callback function. I'm just writing this to help anyone that might have a hard time thinking up a quick example if the come across this question themselves. Example: var numArray = [ 1, 2, 3 ] ; numArray.forEach( function( i ) { console.log( arr[ i - 1 ] ) } ) ; // logs out // 1 // 2 // 3

Anonymous on

0

Is there a front end role at bloomberg. I guess your position must have been labelled software dev right? altho ur a dront end dev

Anonymous on

2

I don't think Bloomberg is a very good company. I am an excellent web developer and have gotten multiple offers from other companies with big names, but was rejected by Bloomberg. They are too demanding during the job interview and it becomes a game of how well you can interview as opposed to how talented an employee you are and how much you can contribute to the growth of the company.

Anonymous on

1

5 vote down star 4 I understand passing in a function to another function as a callback and having it execute, but I'm not understanding the best implementation to do that. I'm looking for a very basic example, like this: var myCallBackExample = { myFirstFunction : function( param1, param2, callback ) { // Do something with param1 and param2. if ( arguments.length == 3 ) { // Execute callback function. // What is the "best" way to do this? } }, mySecondFunction : function() { myFirstFunction( false, true, function() { // When this anonymous function is called, execute it. }); } }; In myFirstFunction, if I do return new callback(), then it works and executes the anonymous function, but that doesn't seem like the correct approach to me.

udaykanth on

Add Answers or Comments

To comment on this, Sign In or Sign Up.

Bloomberg L.P. Careers

Cover image for Bloomberg L.P.

Our teams unleash the power of information and technology to organize, understand, and improve our world. Our 325,000 global customers...More

  • Our Purpose
  • Tech@Bloomberg
  • Bloomberg London
This is the employer's chance to tell you why you should work for them. The information provided is from their perspective.