-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This repository is part of a larger 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.
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.
The items in the picture above have the following meaning:
-
In "Strings" the user sets a string value for the object and one for the primitive. Both are used in "Operations" and "Watch Out!".
-
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.
-
"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.
This knowledge was gained:
Effective JavaScript "68 Specific Ways to Harness the Power of JavaScript" by David Herman