From 8984d9e1668880f07fa947a5c6a08ba9be501f92 Mon Sep 17 00:00:00 2001 From: Osarodion Douglas Idumwonyi Date: Sun, 31 Dec 2023 10:46:03 +0100 Subject: [PATCH] Update 100-primitive-types.md This update highlights the distinction between primitive data types and non-primitives based on the values they hold and the properties and methods they possess. --- .../content/102-javascript-datatypes/100-primitive-types.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/data/roadmaps/javascript/content/102-javascript-datatypes/100-primitive-types.md b/src/data/roadmaps/javascript/content/102-javascript-datatypes/100-primitive-types.md index 13b231110..e97eae2e5 100644 --- a/src/data/roadmaps/javascript/content/102-javascript-datatypes/100-primitive-types.md +++ b/src/data/roadmaps/javascript/content/102-javascript-datatypes/100-primitive-types.md @@ -1,6 +1,10 @@ # Primitive Types -In JavaScript, a primitive (primitive value, primitive data type) is data that is not an object and has no methods or properties. There are 7 primitive data types: +In JavaScript, a primitive (primitive value, primitive data type) is data that is not an object and has no methods or properties. A significant difference between primitive data types and non-primitives is that primitive types can only contain one value, and that value must be of the same primitive type. In contrast, non-primitives can accommodate a variable number of values, and these values can be of different primitive types. This flexibility is evident in data structures like arrays and objects. + +In the context of primitives, it's important to note that they do not possess methods or properties. However, JavaScript enables access to methods and properties associated with primitive types such as string, number, and boolean. this functionality is due to JavaScript's ability to implicitly convert primitives to objects with wrapper objects when necessary. When properties are accessed on primitives, JavaScript auto-boxes the value into a wrapper object and accesses the property on that object instead. + +There are 7 primitive data types: - `string` - `number`