1

I'm the new of JavaScript and I've recently started maintaining someone else's JavaScript code.

The previous code have this block:

someObject.someFunction1.someFuction$i_2 = function somefunction$i_3(x,y){...}

I want to know what does it means? and Is sign"$" just means simply a valid JavaScript identifier? When I use consolo via Chrome, it show me :

typeof someObject = Object
typeof someObject.someFunction1 = function
typeof someObject.someFunction1.someFuction$i_2 = function
typeof somefunction$i_3 = not defined

I just know about :

var functionOne = function() {
    // Some code
};

But, I have no idea about :

x = function function_name(){}
v11
  • 1,684
  • 4
  • 24
  • 47

2 Answers2

3

This is one of the way of defining function in javascript It is commonly called as named function expression

var x = function function_name(){
  //Rest of the code
}

But this function can be called only by calling x() but not by function_name(). function_name only accessible inside the function & is helpful for recursion

Take a look at this & this

brk
  • 43,022
  • 4
  • 37
  • 61
0
  1. The $ sign treated in javaScript in the same way as letters, so it is allowed to have $ as part of the function name. You even can have

    function $(x) {...}

  2. The expression

    x = function function_name(){}

called `named function expression, they are useful when you want to reference the function inside itself. More about why you want to use named function expressions here

Community
  • 1
  • 1
Mikhail Chibel
  • 1,635
  • 1
  • 17
  • 31