mirror of
https://github.com/flynx/Course-JavaScript.git
synced 2025-10-29 11:00:10 +00:00
Compare commits
2 Commits
79fb72406d
...
15da478201
| Author | SHA1 | Date | |
|---|---|---|---|
| 15da478201 | |||
| 8c97e3f073 |
@ -159,22 +159,22 @@
|
|||||||
undefined == null // -> true
|
undefined == null // -> true
|
||||||
|
|
||||||
// But in cases where the same operation is defined for both types
|
// But in cases where the same operation is defined for both types
|
||||||
// the result may seem less predictable, for example `+` defines both
|
// the result may *seem* less predictable, for example `+` defines both
|
||||||
// number addition and string concatination:
|
// number addition and string concatenation:
|
||||||
1 + 2 // -> 3
|
1 + 2 // -> 3
|
||||||
'a' + 'b' // -> 'ab'
|
'a' + 'b' // -> 'ab'
|
||||||
|
|
||||||
// But when mixed it reverts to constructor:
|
// But when mixed it reverts to concatenation:
|
||||||
1 + '2' // -> '12'
|
1 + '2' // -> '12'
|
||||||
|
|
||||||
// This feature can both help make the code simpler and more generic if
|
// This feature can both help make the code simpler and more generic if
|
||||||
// used conciously and at the same time can prove quite frustrating if
|
// used consciously and at the same time can prove quite frustrating if
|
||||||
// neglected.
|
// neglected.
|
||||||
//
|
//
|
||||||
// This neglect and carelessness is the main reason it is quite popular
|
// Note that this neglect and carelessness is the main reason it is quite
|
||||||
// to avoid type coercion and instead overuse strict comparisons and
|
// popular to avoid type coercion and instead overuse strict comparisons
|
||||||
// deffensively over-check everything, at times raised to such levels as
|
// and defensively over-check everything, at times raised to such levels
|
||||||
// to define whole languages (like TypeScript) around this.
|
// as to define whole languages around this (like TypeScript).
|
||||||
|
|
||||||
|
|
||||||
// Type checking
|
// Type checking
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user