# JavaScript

## Variables

A variable is a “named storage” for data. We can use variables to store goodies, visitors, and other data.

There are 3 ways to store a variable using var, let and const.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1713268013213/b489ffb1-e584-4363-be4b-da89643130de.png align="center")

## Data types

### Primitive values

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1713267982633/386fc5c0-c1a9-4726-8f7c-5a64efc9db61.png align="center")

### Dynamic and weak typing.

JavaScript is a [dynamic language](https://en.wikipedia.org/wiki/Dynamic_programming_language) with [dynamic types](https://en.wikipedia.org/wiki/Type_system#DYNAMIC). Variables in JavaScript are not directly associated with any particular value type, and any variable can be assigned (and re-assigned) values of all types.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1713267733075/4bc9d150-ab60-4b77-8c1b-b0efa4677bfa.png align="center")

JavaScript is also a [weakly typed](https://en.wikipedia.org/wiki/Strong_and_weak_typing) language, which means it allows implicit type conversion when an operation involves mismatched types, instead of throwing type errors.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1713267783334/8093fc69-9703-42e4-a28c-c6d38b58866b.png align="center")

### Objects

An object is a value in memory which is possibly referenced by an identifier. In JavaScript, objects are the only mutable values. Functions are, in fact, also objects with the additional capability of being callable.  
  
Object data type contains:

| DataType | **Description** |
| --- | --- |
| Object | represents instance through which we can access members |
| Array | represents group of similar values |

> Type coercion - As mentioned above, JavaScript is a weakly typed language. This means that you can often use a value of one type where another type is expected, and the language will convert it to the right type for you.
