JavaScript is considered to be a loosely typed language because it will attempt to convert data from one type to another in order to be able to execute statements that a more tightly typed language would reject as an error. For example if you try to subtract a text string from a number or a number from a text string provided that the text string can be converted to a number the subtraction will work.
Not all conversions between types happen the way around that some beginners would expect. The + operator is used not just for adding numbers in JavaScript but also for concatenating text strings. Since a number can always be converted to a string but a string can't always be converted to a number JavaScript assumes that if one or more of the fields surrounding the + operator is a string that the intention is to concatenate them together and it will convert any numbers to strings. '1'+1 = '11' rather than 2.
There are some situations where JavaScript will not attempt to convert data types and a couple of examples of where no attempt to convert between data types are comparisons using the === or !== operators (meaning identically equal and not identically equal respectively) and so '1' === 1 evaluates to false while the regular comparison operator '1' == 1 will convert the number to a string before testing for equality and will therefore return true.
Another situation where JavaScript tests for identically equal including the data type as well as the value is with switch/case statements. switch(count) {case '1' ... is the equivalent of if (count === '1') ...
One common cause of JavaScript errors is to assume that JavaScript will convert fields to the correct type for you. The best way to avoid those errors is to avoid using the == and != operators in your if statements and always use === and !== or switch statements instead. The String() and Number() functions will explicitly convert to those data types (or you can use mathematical constructs that are obviously intended to convert to a number such as subtracting zero or multiplying or dividing by one). By doing that you ensure that the conversions between data types takes place when and in the direction that you want rather than having your code perhaps not do what you expect due to its converting between data types in an unexpected way.

