Skip to content

Commit

Permalink
types+grammar: ch1, QC1 edits
Browse files Browse the repository at this point in the history
  • Loading branch information
getify committed Jan 16, 2015
1 parent b5590ee commit f0092ae
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions types & grammar/ch1.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var a = null;
(!a && typeof a === "object"); // true
```

`null` is the only value that is "falsy" (aka false-like; see Chapter 4) but that also returns `"object"` from the `typeof` check.
`null` is the only primitive value that is "falsy" (aka false-like; see Chapter 4) but that also returns `"object"` from the `typeof` check.

So what's the seventh string value that `typeof` can return?

Expand All @@ -104,7 +104,7 @@ a.length; // 2

Since you declared the function with two formal named parameters (`b` and `c`), the "length of the function" is `2`.

What about arrays? They're pretty native to JS, so are they a special type?
What about arrays? They're native to JS, so are they a special type?

```js
typeof [1,2,3] === "object"; // true
Expand Down Expand Up @@ -136,7 +136,7 @@ The `typeof` operator always returns a string. So:
typeof typeof 42; // "string"
```

The first `typeof 42` returns `"number"`, and then `typeof "number"` is `"string"`.
The first `typeof 42` returns `"number"`, and `typeof "number"` is `"string"`.

### `undefined` vs "undeclared"

Expand All @@ -157,7 +157,7 @@ typeof b; // "undefined"
typeof c; // "undefined"
```

It's tempting for most developers to think of the name "undefined" and think of it as a synonym for "undeclared." However, in JS, these two concepts are quite different.
It's tempting for most developers to think of the word "undefined" and think of it as a synonym for "undeclared." However, in JS, these two concepts are quite different.

An "undefined" variable is one that has been declared in the accessible scope, but *at the moment* has no other value in it. By contrast, an "undeclared" variable is one that has not been formally declared in the accessible scope.

Expand Down

0 comments on commit f0092ae

Please sign in to comment.