-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This repository is part of a larger project!
Javascript objects like JSON or Math can be converted to strings by calling the toString method and to numbers by calling the method valueOf.
Javascript allows to define these methods. As an example a following code section from the file "objects.js" shall be shown:
var container =
{
toString: function()
{
return str.value;
},
valueOf: function()
{
return num.value;
}
};
A general question could occur here: "Which method does javascript prefer when using the plus operator?" It is valueOf and the purpose of this project is to show that.
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