Golang Tutorials - Learn Go Programming with Easy Step-by-Step Guides

Explore comprehensive Golang tutorials for beginners and advanced programmers. Learn Go programming with easy-to-follow, step-by-step guides, examples, and practical tips to master Go language quickly.

Js Data Types in JavaScript

Js Data Types in JavaScript

? JavaScript Data Types


JavaScript has 7 primary data types, divided into primitive and non-primitive:


1. Primitive Data Types

TypeDescriptionExample
NumberRepresents both integers and floating points42, 3.14, NaN
StringSequence of characters"Hello", 'JS'
BooleanLogical true/false valuestrue, false
UndefinedVariable declared but not assignedlet x; // x is undefined
NullRepresents intentional absence of valuenull
BigIntFor very large integers beyond Number range9007199254740991n
SymbolUnique and immutable identifierSymbol('id')

2. Non-Primitive Data Type (Objects)

  • Objects are collections of key-value pairs.

  • Arrays, functions, dates, etc. are specialized objects.

const obj = {name: "Alice", age: 25};const arr = [1, 2, 3];

Examples:

typeof 42;           // "number"typeof "hello";      // "string"typeof true;         // "boolean"typeof undefined;    // "undefined"typeof null;         // "object" (this is a quirk in JS)typeof 10n;          // "bigint"typeof Symbol('id'); // "symbol"typeof {};           // "object"typeof [];           // "object"typeof function(){}; // "function"

Notes:

  • null is a primitive but typeof null returns "object" (historical bug).

  • function is a special callable object.

  • JavaScript is dynamically typed, so variables can hold any data type.


Want me to explain type coercion, checking types, or how to convert between types?

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql