11 things about JavaScript functions .NET developers must know: Part 1

I have often seen .NET developers struggle with the JavaScript. They try to compare C# functions with the JavaScript functions and usually do some minor but conceptual mistakes while using it. As we all will agree that JavaScript functions are the backbone of the JavaScript programming language, and if one has good understanding of the function then using JavaScript is easier. So in this two parts series, I will focus some important concepts of JavaScript functions.

In this part of the series, we will cover the following six topics:

  1. JavaScript function as an expression
  2. JavaScript function as a statement
  3. Return statement in the JavaScript function
  4. Parameters in the JavaScript function
  5. Arguments object in the JavaScript function
  6. Varargs JavaScript function

JavaScript functions can be an expression

A JavaScript function can be an expression. You can create a JavaScript function as an expression as shown below:

image

A function expression creates an instance of the function object. It can be passed as an argument to a function, it can be returned from a function, and it can be assigned to a variable or an array. A function expression can be created with the name as shown follows:

Read full article on the Infragistics blog

3 responses to “11 things about JavaScript functions .NET developers must know: Part 1”

  1. Interesting article, but explaining the “why” would be helpful. I can create a function using “var add = function Add(n1, n2)” or “var add = function(n1,n2)”. Great, but what’s the difference between the two? Why would I choose to do one or the other? And why would I create a function that allows the caller to pass in values that I expect but I don’t specify? Is it the equivalent to using “params” in .NET? Given that the title is about .NET developers knowing JavaScript, I would assume so, but making that connection would have been more clarifying.

  2. Interesting article, but explaining the “why” would be helpful. I can create a function using “var add = function Add(n1, n2)” or “var add = function(n1,n2)”. Great, but what’s the difference between the two? Why would I choose to do one or the other? And why would I create a function that allows the caller to pass in values that I expect but I don’t specify? Is it the equivalent to using “params” in .NET? Given that the title is about .NET developers knowing JavaScript, I would assume so, but making that connection would have been more clarifying.

  3. In further posts I will write WHY also ! Thanks for the reading and comment !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com