
What are they primitive data types and non-primitive data types and difference?
Primitive and Non-primitive data-types in JavaScript. Variables hold values, and every value has a specific data type that defines the kind of information it holds. These data types are broadly categorized into two groups: Primitive Data Types and Non-Primitive Data Types. Let us discuss it one by one. Primitive Data Types: Primitive data types are the built-in data types provided by JavaScript. They represent single values and are not mutable. JavaScript supports the following primitive data types: 1.1 Number: Number data type in JavaScript can be used to hold decimal values as well as values without decimals. Example: let x = 250; let y = 40.5; console.log("Value of x=" + x); console.log("Value of y=" + y); Output Value of x=250 Value of y=40.5 1.2 String: The string data type in JavaScript represents a sequence of characters that are surrounded by single or double quotes. Example: let str = 'Hello All'; let str1 = "Welcome to my new house"; console.log("Value of str=" + str); consol
Continue reading on Dev.to
Opens in a new tab
