Interview Question

Front End Web Developer Interview

-New York, NY

Bloomberg L.P.

What is a JavaScript callback function?


Interview Answers

5 Answers


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


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


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


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


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.