11 things about JavaScript functions every .NET developer should know: Webinar Recap

Dhananjay Kumar / Wednesday, May 20, 2015

We recently held a webinar for the Indian region on March 27th, titled “11 things about JavaScript function every .NET developer should know”.

The presentation was attended by a good number of developers from the Indian region, and I covered a range of topics, including:

  • Functions as a statement
  • Functions as an expression
  • Return statements
  • Arguments in Javacript functions
  • JavaScript functions as constructors
  • Callback functions, and more

Many questions were asked during the webinar, and while we tried to answer all of them, we may have missed some, so here are some of the important questions followed by our answers:

What is function as expression and statement?

When we create a function and assign that to a variable then this is known as “function as an expression”. Whereas a function created with the first word function is known as a function statement. A function statement gets hoisted at the top of the scope.

Which editor you are using?

We are using Sublime text 2 and running JavaScript using NodeJS.

What function as constructor returns?

If we invoke a function after the new keyword, then function acts as a constructor and returns the created object. In the function, this represents the current object.

How do parameters work in JavaScript functions?

  • do not check for the type of parameters
  • do not check for the number of parameters
  • along with parameters arguments object, an array like object
  • arguments object length property gives us the number of parameters passed while invoking the function
  • We can pass more or less parameters while invoking a function

How do return statements work in JavaScript functions?

  • A JavaScript function may or may not have the return statement.
  • A Function without a return statement returns undefined
  • A Function with only a return statement returns undefined
  • A Function with a return statement along with an expression returns the evaluated value of the expression
  • A Function constructor returns a newly created object

What is a JavaScript callback function?

JavaScript callback functions have two attributes:

  1. They get passed as parameter to a function
  2. They get inside body of a function

Once again, thank you so much for your interest in our webinars – and we look forward to seeing you at a future presentation!