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

Welcome to the Javascript-valueOf-and-toString- wiki!

This repository is part of a larger project!

◀️ PREVIOUS PROJECT| NEXT 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.

Clone this wiki locally