# Functions as Object

* The constructor of the function is an Object.

```javascript
Ex 1:
function welcome() {
    console.log("Wlecome"); // Welcome
}

welcome.greeting = "Hello";

Ex 2:
const obj = {
    greet() {
        console.log("Hello");
    }
};

obj.greet(); // Hello

```

In the above example 1 we declared a function welcome. We can print `"Welcome"` by calling as `welcome();`. Instead we can also use `call()` and `apply()` methods to call the same function. We know that `Object` only has the `key values`. Now clearly understood that function is also an Object.

```javascript
// under the hood of Ex 1
const welcome = {
    name: 'welcome',
    greeting: 'Hello',
    (): console.log("Wlecome")
}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://javascript-1.gitbook.io/javascript/functions-as-object.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
