Skip to content
Akin C edited this page Apr 13, 2020 · 18 revisions

Welcome to the Javascript-overloaded-plus-operator- wiki!

This repository is part of a larger project!

◀️ PREVIOUS PROJECT| NEXT PROJECT ▶️


In Javascript the operator "+" allows not only to sum "number" values but also to concatenate two or more strings.

The operator has another interesting feature which permits turning a string into a "number".

With the help of an example this will be now explained:

1. A text box in HTML is generated as follows

<input type="text" id="txt_one">

2. The value from the text box is fetched and converted as follows

<script>
  var myValue = +document.getElementById("txt_one").value;
</script>

There is an issue here which is the lack of knowledge from my side, how the converting property is working! If you at any rate know some explanation or better a valid source, please post it under the section Issues in this github project!Thank you very much!

🥇 The ISSUE has been solved by dotnetCarpenter

Content

Starting "index.html" in a web browser should show a content as seen below. ERROR: Missing Picture

There are three sections in the picture.

1. Section "Addition" allows to calculate the sum of two numbers.

2. Section "Concatenating strings" allows to concatenate two strings to one.

3. Section "Pitfall examples" shows some examples which can produce results that should be avoided.

The results could be displayed as shown in the picture below.

ERROR: Missing picture!

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