0
$\begingroup$

If javascript's object is just associative array, what makes it non-primitive as they have labeled it? It is certainly already built in. Its not like I'm creating my own concrete implementation of associative array before i begin coding on it.

According to wiki's quote:

Primitive data types or built-in data types are types that are built-in to a language implementation. User-defined data types are non-primitive types. For example, Java's numeric types are primitive, while classes are user-defined.

There is another quote

Primitive types are almost always value types, but composite types may also be value types.

Why is primitive type mostly value type and not reference type? it doesn't have any correlations to the first quote 'built-in data types are types that are built-in',

https://en.wikipedia.org/wiki/Primitive_data_type

$\endgroup$

1 Answer 1

1
$\begingroup$

A term means exactly what the person using the term defines it to mean. No more, no less.

The ECMAScript Language Specification defines the term primitive value as follows:

4.4.5 primitive value

member of one of the types Undefined, Null, Boolean, Number, BigInt, Symbol, or String as defined in clause 6

If javascript's object is just associative array, what makes it non-primitive as they have labeled it?

Because the definition of primitive in the ECMAScript Language Specification says so.

According to wiki's quote:

Primitive data types or built-in data types are types that are built-in to a language implementation. User-defined data types are non-primitive types. For example, Java's numeric types are primitive, while classes are user-defined.

There is another quote

Primitive types are almost always value types, but composite types may also be value types.

Why is primitive type mostly value type and not reference type? it doesn't have any correlations to the first quote 'built-in data types are types that are built-in',

If the two quotes don't agree, then the most likely reason is that they were written by two different people who use two different definitions of the term "primitive".

Essentially, what you have here is four understandings of what the term "primitive" means:

  • Yours,
  • ECMASCript's,
  • the first quote's author's, and
  • the second quote's author's.

Before you start comparing statements and conclusions between those four, you first need to verify that all of those four use the same definitions of the terms you are comparing. I.e. you need to make sure that all four (including yourself) use the same definitions for terms such as "primitive", "composite", "user-defined", "built-in", "value type", and so on.

Just as an example: the first quote defines "primitive types" to be the same as "built-in types" and contrasts it with "user-defined types". The second quote contrasts "primitive types" with "composite types". So, the first quote is concerned with who defines the type, the second quote is concerned with whether the type is made up of a single piece or multiple pieces.

Those two are completely different things, so it should be no surprise that they come to different conclusions: for example, Objects are built-in types in ECMAScript, therefore, they are primitive according to the first quote, but they are also composite which means they are not primitive according to the second quote, and we have already established that they are also not primitive according to the ECMAScript Language Specification.

Note: you wrote that you found those quotes on the Wiki, but I couldn't find them anywhere on the Wiki, so I was not able to examine the wider context.

By the way, this is in no way specific to primitive types or to Computer Science or even to Science in general. E.g. the term "football" means very different things even to speakers of the same language, e.g. people from the UK or people from the US. In Germany, "liberals" are people who advocate for small government, against government spending, against social security and public healthcare, whereas in the US, those would be called "conservative" and liberals are the exact opposite.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.