DEV Community

Francisco Imanol Suarez
Francisco Imanol Suarez

Posted on

πŸ§πŸ€“Data types and values in Javascript πŸ’»

The data type is a property of a value that determines the values it can take, what types of operations we can perform on it and how its internal representation.
In JavaScript we find different types of values and data types to store in variables.

Values and types
Main (primitive) types

string number boolean

Composite type

Object
Array

Special type

Null
Undefined

In the case of ES6, a new type of this denomination type is presented as a symbol data type whose values are unique and cannot be changed.

JavaScript provides an operator called typeof, this operator can examine a value and tell it what type it is:

Typeof image

This operator is special since it allows us to know the type (number, boolean, undefined, object) that the variable has on which we are going to perform an action.

✨ String

A string value is a set of Unicode characters (letters, digits, punctuation, and more), this data type is responsible for rendering the text in JavaScript

Alt Text

πŸ’‘ Number

In JavaScript, no distinction is made between integer and floating point values; a JavaScript number can be any one of them (internally, JavaScript represents all numbers as floating point values).

Alt Text

πŸ’‘ Boolean

This data type stores 1 bit can be true or false, they are used to record a state (TRUE OR FALSE)

Alt Text

πŸ’‘ Objects

Since JavaScript is designed in an object-based paradigm. We say that an object is a collection of properties, these objects can be compared to tangible objects in real life.

Alt Text

Another way to access the properties of these objects is as follows:
Alt Text

Access (by index) an Array element
Alt Text
Now if we think about the name of position [1], it should be Mariano, well, when starting to program this may sound a bit strange, but in programming we start counting from the number zero (0).

πŸ’‘ Undefined

This data type is used when we do not know the content of a variable or it has not yet been defined.
Alt Text

πŸ’‘ Null

The nulldata type has only the null value. Null reserved keyword cannot be used as a function or variable name
A variable containing nulldoes not contain any type of boolean number, string or value, nor an array or object. This data type is not 0 like in other languages like C or C ++, declaring a variable of type null and using the operator typeof it interprets the value as Object not as null type

Thanks for reading πŸ’»
πŸ€“ You can follow me on Twitter or find me on GitHub by visiting my website
https://about.me/franciscoimanol

Top comments (1)

Collapse
 
franciscoimanolsuarez profile image
Francisco Imanol Suarez

You're right, excuse me, I'll modify it and put it as Array, do you think that's okay?