# Interview Questions

{% tabs %}
{% tab title="Question" %}

## What is hoisting in javascript?

{% endtab %}

{% tab title="Answer" %}
Hoisting is JavaScript's default behavior of moving all declarations to the top of the current scope (to the top of the current script or the current function).

**Hoisting** is the mechanism of moving the variables and functions declaration to the top of the function scope (or global scope if outside any function).

* <https://dmitripavlutin.com/simple-but-tricky-javascript-interview-questions/>
* <https://dmitripavlutin.com/javascript-hoisting-in-details/>
  {% endtab %}
  {% endtabs %}

{% tabs %}
{% tab title="Question" %}

## Write a function to reverse a hashmap/object. so set the values as properties and properties as values

{% endtab %}

{% tab title="Answer" %}

```javascript
const j = {
 a: "a1",
 b: "b2",
 c: "c3"
}

const y = Object.keys(j).reduce((a, c) => {
 a[j[c]] = c;
 return a;
}, {});
```

{% endtab %}
{% endtabs %}


---

# 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://ysk.snesjhon.com/javascript/interview-questions.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.
