JavaScript

JavaScript

An overview of javascript fundamentals

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.

Data types

Primitive values

Dynamic and weak typing.

JavaScript is a dynamic language with dynamic types. 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.

JavaScript is also a weakly typed language, which means it allows implicit type conversion when an operation involves mismatched types, instead of throwing type errors.

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:

DataTypeDescription
Objectrepresents instance through which we can access members
Arrayrepresents 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.