<p>JavaScript allows functions to be treated as objects--if you first define a variable as a function, you can subsequently add properties to that function.  How do you do the reverse, and add a function to an "object"?</p>

<p>This works:</p>

<pre><code>var foo = function() { return 1; };
foo.baz = "qqqq";
</code></pre>

<p>At this point, <code>foo()</code> calls the function, and <code>foo.baz</code> has the value "qqqq".</p>

<p>However, if you do the property assignment part first, how do you subsequently assign a function to the variable?</p>

<pre><code>var bar = { baz: "qqqq" };
</code></pre>

<p>What can I do now to arrange for <code>bar.baz</code> to have the value "qqqq" <em>and</em> <code>bar()</code> to call the function?</p>

JavaScript allows functions to be
  treated as objects--you can add a
  property to a function. How do you do
  the reverse, and add a function to an
  object?
You appear to be a bit confused. Functions, in JavaScript,
are
objects. And
variables
are
variable
. You wouldn't expect this to work:
```
```
var three = 3;
three = 4;
assert(three === 3);
```
```
...so why would you expect that assigning a function to your variable would somehow preserve its previous value? Perhaps some annotations will clarify things for you:
```
```
// assigns an anonymous function to the variable "foo"
var foo = function() { return 1; }; 
// assigns a string to the property "baz" on the object 
// referenced by "foo" (which, in this case, happens to be a function)
foo.baz = "qqqq";
```
```