# Expressions

## Rules

1. Can be anonymous.
2. Cannot be hoisted.

## File Location

We will be working in the following file:

```
    javascript-library
        └── 0-PreWork
        └── 1-Fundamentals
            └── 1-Grammar-and-Types
            └── 2-ControlFlow-and-ErrorHandling
            └── 3-Loops
            └── 4-Functions
                02-expressions.js <----You will be working in this file.
```

## Anonymous Functions

When we say that function expressions can be anonymous, you'll see below that the function does not have a name after the `function` keyword is used:

```javascript
var sayHello = function(){
    console.log("Hello");
}
```

## Naming a function expression

You can also put a name on a function expression:

```javascript
var sayHowdy = function howdy(){
    console.log("Howdy");
}

//Printing the value
console.log(sayHowdy());
```

## No Hoisting

Function expressions CAN NOT be hoisted in JavaScript. This means that the call can not come before the function is declared.

```javascript
//The call - this would cause an error
fooFunction(); 

//The expression
var foo = function fooFunction() {
  console.log('foo');
}
```

## Practice

Practice writing 3 different function expressions of your own choosing.


---

# 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://eleven-fifty-academy.gitbook.io/javascript-101-fundamentals/1-javascript-fundamentals/1-js-fundamentals/4-functions/expressions.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.
