Primitives are not enough.
Primitive values such as string and numbers are the most basic holders or binders you can work with in JavaScript.
JS provides other data structure to work with complex data. Things like arrays allow you to work with ordered sequence of values can be numbers, string or other complex data structure.
Methods on complex data structure.
-
since data structure are simply objects, most of them come with build in methods (which are just functions bounded to these data structure)
-
An example with the Array data structure, which provides methods such ad push(add something at the lest of the array) or pop which does the inverse.
-
The object data structure is also another powerful complex structure, which stores things in a non linear or perhaps unordered way.
- It stores values in a key value pair.
- Of which the key is simply a string.
- And the value can be either primitive or complex data type.
- It stores values in a key value pair.