-String
-Integer
-Boolean
-Array
-Object
- String: The string data type is used to represent textual data. Strings are created using single or double quotes surrounding one or more alphabet characters, spaces, numbers and special characters.Example:
var projectName = "Data types"
- Integer: This data type is used to represent positive or negative numbers with or without decimal place, or numbers written using exponential notation.Example:
var myAge = 28
- Boolean: The Boolean data type can hold only two values: true or false. It is typically used to store values like yes (true) or no (false), on (true) or off (false).Example:
var isLoggedIn = true
- Array: An array is a type of object used for storing multiple values in single variable. Each value in an array has a numeric position, known as its index, and it may contain data of any data type-numbers, strings, booleans, functions, objects, and even other arrays.Example:
var godfatherTrilogy = ["Mov 1", "Mov 2", "Mov 3"]
- Object: An object contains properties, defined as a key-value pair. A property key is always a string, but the value can be any data type, like strings, numbers, booleans, or complex data types like arrays, function and other objects.Example:
var dataTypesAssigment = { data 1: ["String"], data 2: ["Integer"], data 3 ["Boolean"], data 4 ["Array"], data 5 ["Object"]}
JavaScript Logo