[[Analog vs Digital|Digital Data]] is, at is core, a [[Data Serialization|serialized]] sequence of [[Binary]] numbers in order. We [[Character Encoding|encode]] bits & bytes of binary to allow the zeros and ones to enable them to represent more sophisticated pieces of information, such as numbers or unicode characters. Every programming language allows you to work with multiple [[Data Types]][^1]. Some languages are **strongly typed** (e.g. [[Rust]], [[C++]], etc), where any declared variable is "typed" at the time of its declaration, and its type is not allowed to change. Other languages are **dynamically typed** (e.g. [[Python]], [[JavaScript]]), where types are inferred from usage and *a variable's data type is allowed to change as it's used*. When one data type is converted to another, this is referred to as **coercion**. #todo - is data type change *always* coercion? ## In JavaScript In JavaScript, type coercion can be done *implicitly*. ```javascript let age = 6; /* age is a number, but can be implicitly coerced to act as a string */ let birthdayMsg = "Congratulations to the happy " + age + " year old!"; ``` Any variable type and value may be called "**truthy**" if it's evaluated as `true` when coerced to a [[Boolean Logic|boolean]]. This leads to some confusion, especially among ME when I was first learning to code. ## In Python In Python, despite being a dynamically typed language, type coercion must be done explicitly. This is in line with [[The Zen of Python]]. ```python age = 6 # age must be explicitly coerced to a string using the `str()` function birthdayMsg = "Congratulations to the happy " + str(age) + " year old!" ``` **** # More ## Source - self [^1]: I think? I mean, is there one that doesn't?