Skip to content
Akin C edited this page Apr 15, 2018 · 15 revisions

Welcome to the Javascript-object-and-primitive-strings- wiki!

This repository is part of a larger project!

◀️ PREVIOUS PROJECT| NEXT PROJECT ▶️


Javascript has five types of primitive values and these are boolean, number, string, null and undefined. Beside those five there is also the type called object.

Even though the typeof operator reports type object for the type null, it is defined by ECMA standards as an own type.

Javascript allows to create a string object which can be concatenated with other string values. Extracting a specific character from the object is also possible.

One important thing to note is that a string object is never equal to another string object even though they have the same value. It is only equal to itself.

A primitive string has similar object features like calling methods or extracting properties.

It is possible to assign properties to objects but not to primitives and so it seems that the only advantage of objects over primitives is to assign properties.

Content

The user interaction part after setting some input values should look like the content as seen below by starting "index.html" in a web browser.

ERROR: No Image found!

The items in the picture above have the following meaning:

  1. In "Strings" the user sets a string value for the object and one for the primitive. Both are used in "Operations" and "Watch Out!".

  2. In "Operations" primitive and object string are concatenated and a character is extracted from the object by inputing the position. Also toUpperCase method is used on the primitive one.

  3. "Watch Out!" shows for one, the type of both strings and second the truthiness of two string objects with the same string value.

The colored areas are just for a better readability in the wiki and are not part of the content. To use the project just download the files and execute "index.html". Note that all files should be placed in the same folder so that the functionality of the code is guaranteed.

Clone this wiki locally