JavaScript Datatypes

Javascript has several built-in data types that are used to represent different kinds of values. Here are the main data types in javascript:


1. **PRIMITIVE TYPES:**

- **Number**: represents numeric values, including integers and floating-point numbers.
For example, `5` or `3.14`.
- **string**: represents a sequence of characters. Strings are enclosed in single quotes (`'`) or double quotes (`"`). For example, `'hello'` or `"javascript"`.
- **boolean**: represents a logical value, either `true` or `false`.
- **null**: represents the absence of any object value. It is a special value and considered a primitive type.
- **undefined**: represents an uninitialized or undefined value. If a variable is declared but not assigned a value, it is `undefined`. It is also a primitive type.
- **symbol**: introduced in ecmascript 6, symbols are unique and immutable values that can be used as object keys for property identification.


2. **COMPLEX TYPES:**

- **OBJECT**: represents a collection of key-value pairs and is one of the most important data types in javascript. Objects can be created using object literals (`{}`), the `new` keyword, or built-in constructors like `array`, `date`, etc.
- **ARRAY**: represents an ordered list of values. Arrays can contain elements of any data type and are created using square brackets (`[]`). For example, `[1, 2, 3]`.
- **FUNCTION**: represents a reusable block of code that can be invoked by its name. Functions are objects in javascript and can be assigned to variables or passed as arguments to other functions.


These are the core data types in javascript. Javascript is a dynamically-typed language, meaning variables can hold values of any type, and the data type is determined at runtime. Additionally, javascript has some built-in methods and functions to work with these data types.



About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc





 PreviousNext