Why a String Can Reach a Math Operation
In a dynamically typed language, a variable’s type is associated with the value it holds at runtime, rather than being fixed in advance by a declaration the compiler checks throughout the program. That can make it possible to call a subtraction function with a text value such as `"8"` and a number such as `3`: the function call itself may not be rejected before execution.
The important distinction is between getting a value to the operation and being able to perform the operation. When the program reaches the subtraction, the language must decide what to do with those values. It might convert the text to a number, if its rules allow that, or raise an error because text and numbers cannot be subtracted. Dynamic typing does not guarantee that the calculation will work.
The Check Happens When the Code Runs
A statically typed language can often flag a mismatch earlier, while compiling or analyzing the code. In a dynamically typed language, the problem may surface only when execution reaches that particular call. If the call sits on a rarely used branch, the error can remain hidden until that branch runs.
This shifts some work from an early type check to the running program. Developers may add tests or explicit checks—such as verifying that an input is numeric—so bad values are caught before they reach arithmetic. The practical consequence is that a function can accept a broader range of inputs at the call site, but the actual operation still depends on the values it receives.

![Why [] + [] becomes an empty string](https://cdn.stackyfacts.com/images/d1aa02bf-a013-4e2f-8dcf-21df6e97df10_back.jpg)




