JavaScript 7 ๐งฌ Automatic type conversion and typeof operator
a - Automatic data type conversion
JavaScript automatically converts data types between strings, numbers and boolean
This process is also known as implicit type conversion
console.log(1 + '2'); โ automatically convert 1 to string, result: 12
console.log('10' - '4'); โ both strings are converted to numbers, result 4
console.log('10' + 4); โ result 104
console.log(5 * null) โ null becomes 0, result 0
console.log(5 * true) โ true becomes 1, result 5
console.log(5 * false) โ false become 0, result 0
b - typeof operator
typeof operator is used to determine the type of a variable or value.
It returns a string indicating the type of the unevaluated operand.
This can be particularly useful for debugging and ensuring that variables are of the expected types.
console.log(typeof 42); โ result: number
console.log(typeof ""); โ result: string
console.log(typeof true); โ result: boolean
declared variable example โ result: undefined
object example โ result: object
function example โ result: function
Stop using slow, ad-bloated tool sites! ๐คฎ
๐ Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
โ
Finance (Mortgage, Interest, Inflation)
โ
Tech (Base64, JSON, Dev Suite, IP)
โ
Health (BMI, BMR, TDEE)
โ
Productivity (Timer, Workspace, QR)
โก๏ธ Fast & Private
๐ No data leaves your device
๐ 100% Free
๐ Use it now: https://tools.kandz.me
๐ Bookmark itโyouโll need it later!