Data Types in javascript

Data Types in javascript

JavaScript supports various data types that help you work with different kinds of values. Here are some of the fundamental data types in JavaScript, along with brief explanations.

  1. Primitive Data Types:Number: Represents numeric values, e.g., 5, 3.14.String: Represents textual data, e.g., "Hello, world!".Boolean: Represents either true or false.Undefined: Represents a variable that has been declared but not assigned a value.Null: Represents the intentional absence of any object value.
  2. Complex Data Types:Object: Represents a collection of key-value pairs. Objects can be used to group related data and functions, making it easy to organize and access them. Objects can be used to handle images indirectly by, for example, representing an image with properties like width, height, and source.Array: Represents an ordered list of values. You can store multiple values in a single array variable.
  3. Special Data Types:Symbol: Introduced in ECMAScript 6, symbols are unique and immutable primitive values, often used as keys in objects to avoid naming collisions.BigInt: Also introduced in ECMAScript 6, BigInt is used for representing arbitrary precision integers.

Now, let's create a simple example that uses these data types, though it won't directly involve image

Creating an object to represent an image

var image =

{ src: "https://via.placeholder.com/300",

URL of the image width: 300,

Width of the image height: 200,

Height of the image description: "A sample image",

Description of the image isVisible: true ,

Whether the image is currently visible on the page };

To view or add a comment, sign in

Explore content categories