mirror of
https://github.com/flynx/Course-JavaScript.git
synced 2025-10-29 02:50:09 +00:00
Compare commits
2 Commits
ee6471a627
...
e756865491
| Author | SHA1 | Date | |
|---|---|---|---|
| e756865491 | |||
| 9125af6047 |
@ -26,16 +26,17 @@
|
|||||||
//
|
//
|
||||||
// Imagine an apple, it's a "thing" that is an "apple", or we say that
|
// Imagine an apple, it's a "thing" that is an "apple", or we say that
|
||||||
// it has a value "apple". There are lots of apples in the world,
|
// it has a value "apple". There are lots of apples in the world,
|
||||||
// each one is different but all are apples. Now imagine two people,
|
// each one is slightly different but all are apples. Now imagine two
|
||||||
// each looking at an apple, we can say that each person sees the value
|
// people, each looking at an apple, we can say that each person sees
|
||||||
// "apple", those values are equal, and if those people are sitting at
|
// the value "apple", those values are equal, and if those people are
|
||||||
// the same table and looking at the same apple, we say that their
|
// sitting at the same table and looking at the same apple, we say that
|
||||||
// apples are the same, or they are of the same identity, (i.e. the
|
// their apples are the same apple, or in JavaScript-ish, they are of
|
||||||
// same apple).
|
// the same identity.
|
||||||
// Then if we can take a different set of people looking at apples, but
|
// Then if we can take a different set of people looking at apples, but
|
||||||
// now each one has their own personal apple, the values are still the
|
// now each one has their own personal apple, the values are still the
|
||||||
// same, both apples are still apples but now they are different apples,
|
// same, both apples are still looking at apples but now their apples
|
||||||
// aren't they? And thus we say they are of different identities.
|
// are different, aren't they? And thus we say they are of different
|
||||||
|
// identities.
|
||||||
// We'll come back to this concept a bit later, once we introduce
|
// We'll come back to this concept a bit later, once we introduce
|
||||||
// JavaScript values and types.
|
// JavaScript values and types.
|
||||||
//
|
//
|
||||||
@ -49,7 +50,7 @@
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Note that all numbers are of the same "type", this is different to
|
// Note that all numbers are of the same "type", this is different to
|
||||||
// allot of other languages where numbers are represented closer to the
|
// allot of other languages where numbers are implemented closer to the
|
||||||
// low-level hardware implementation and thus are represented by a
|
// low-level hardware implementation and thus are represented by a
|
||||||
// whole range of number types.
|
// whole range of number types.
|
||||||
//
|
//
|
||||||
@ -58,12 +59,35 @@
|
|||||||
var oct = 052
|
var oct = 052
|
||||||
var hex = 0xFF
|
var hex = 0xFF
|
||||||
var dec = 42
|
var dec = 42
|
||||||
|
var exp = .42e2
|
||||||
|
|
||||||
//
|
//
|
||||||
// But note that these are just different notations and all of the
|
// But note that these are just different notations and all of the
|
||||||
// above resolve to the same number.
|
// above resolve to the same number.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
// Numbers also have several limitations:
|
||||||
|
//
|
||||||
|
// - precision, rounding errors and fractions (IEEE-754)
|
||||||
|
0.1 + 0.2 == 0.3 // -> false
|
||||||
|
|
||||||
|
// XXX
|
||||||
|
|
||||||
|
// - large number rounding
|
||||||
|
Number.MAX_SAFE_INTEGER + 10 - 10 == Number.MAX_SAFE_INTEGER
|
||||||
|
|
||||||
|
// In general numbers larger than Number.MAX_SAFE_INTEGER and
|
||||||
|
// smaller than Number.MIN_SAFE_INTEGER should not be used for
|
||||||
|
// math operations (see BigInt).
|
||||||
|
//
|
||||||
|
// Note that neither issue is specific to JavaScript but rather are
|
||||||
|
// side-effects of number implementations in modern computers and
|
||||||
|
// the trade-offs of these implementation on each level from the
|
||||||
|
// CPU to the high-level languages.
|
||||||
|
//
|
||||||
|
// For more details see:
|
||||||
|
// XXX
|
||||||
|
|
||||||
|
|
||||||
// Strings
|
// Strings
|
||||||
var string = 'string'
|
var string = 'string'
|
||||||
@ -75,10 +99,12 @@
|
|||||||
|
|
||||||
// XXX a note on template strings
|
// XXX a note on template strings
|
||||||
|
|
||||||
// Boolieans
|
|
||||||
|
// Booleans
|
||||||
var t = true
|
var t = true
|
||||||
var f = false
|
var f = false
|
||||||
|
|
||||||
|
|
||||||
// Nulls
|
// Nulls
|
||||||
var n = null
|
var n = null
|
||||||
var u = undefined
|
var u = undefined
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user