# Javascript

*JavaScript* was initially created to “make web pages alive”.

The programs in this language are called *scripts*. They can be written right in a web page’s HTML and run automatically as the page loads.

Scripts are provided and executed as plain text. They don’t need special preparation or compilation to run.

## **Utilities**

In single line of code! No more! - \[<https://1loc.dev/]\\(https://1loc.dev/]\\(https://1loc.dev/)>

Compatibility table - \[<https://kangax.github.io/compat-table/es6/]]\\(https://kangax.github.io/compat-table/es6/>])

Run a local web server to run JS modules

```js
# Step 1: Install http-server package 
npm install http-server -g 

# Navigate to the directory 
$ cd /opt/sites/blog 

# Launch HTTP server 
$ http-server 

# Launch HTTP server on port 4000 
$ http-server -p 4000
```

### Concepts

* [Higher Order Function](https://dev.to/atapas/higher-order-functionshof-in-javascript-explain-like-im-five-402f)
  * Composability: function inside a function - that is called functional programming to take the advantage of reusability, less code, etc.,
  * JS high-order function: .map(), .filter(), .reduce(), .find()
  * Higher order functions is not same as callback. Pass as an argument to higher-order function.
* [Debounce](/wiki/code/what-is-debounce.md)


---

# 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://www.logeshpaul.com/wiki/code/javascript.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.
