# Function fName() vs. fName = function() \[FMX\]

**URL:** https://forum.kirupa.com/t/function-fname-vs-fname-function-fmx/123253
**Category:** Uncategorized
**Created:** [September 22, 2004, 12:26am UTC](https://forum.kirupa.com/t/function-fname-vs-fname-function-fmx/123253 "2004-09-22T00:26:31Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![kill\_robot\_kill](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kill_robot_kill/32/359_2.png) [@kill\_robot\_kill](https://forum.kirupa.com/u/kill_robot_kill)
#### Post date: [September 22, 2004, 12:26am UTC](https://forum.kirupa.com/t/function-fname-vs-fname-function-fmx/123253/1 "2004-09-22T00:26:31Z")

</div>

Ok, so I am messing around with some code and noticed that there is a difference between these two function declerations.

```auto
function fName(){//}
fName = function(){//}

```

I’ve always used **function fName()** before, but I am starting to learn some OOP, and figured I could change to **fName = function()** to indicate that it is a constructor. I thought it was a pretty good idea, until my code started behaving off.

An example of this is:

```auto

function Animal() { // Animal Constructor
}
Cat.prototype = new Animal(); 
function Cat() { // Cat Constructor
} 

```

If I type the “cat constructor” as **Cat = function()** it doesn’t work unless its before “cat.prototype”, now if I leave it as is, it will work if its called before or after the cat.prototype.

Why is that, should I NEVER use\*\* fName = function()\*\* to declare a function, or is my example just off? I guess I’m just looking for an explanation of this.
