Better punctuations

This commit is contained in:
K-Sato 2019-07-02 10:05:56 +09:00 committed by GitHub
parent 94c83e9e50
commit 37799fb45e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,7 +3,7 @@
What happens when objects are added `obj1 + obj2`, subtracted `obj1 - obj2` or printed using `alert(obj)`?
In that case objects are auto-converted to primitives, and then the operation is carried out.
In that case, objects are auto-converted to primitives, and then the operation is carried out.
In the chapter <info:type-conversions> we've seen the rules for numeric, string and boolean conversions of primitives. But we left a gap for objects. Now, as we know about methods and symbols it becomes possible to fill it.
@ -138,7 +138,7 @@ alert(+user); // valueOf -> 1000
alert(user + 500); // valueOf -> 1500
```
Often we want a single "catch-all" place to handle all primitive conversions. In this case we can implement `toString` only, like this:
Often we want a single "catch-all" place to handle all primitive conversions. In this case, we can implement `toString` only, like this:
```js run
let user = {