One line of code creates a lot of confusing

"// obj.toString === obj.__proto__.toString == Object.prototype.toString"
It is look like JS code but it gives different result from what we want to get.
There is different kind of equality operator ant these give more confusing what is the purpose of these?
It can be better to separate this line into 2 line of code to make it sensible and readable.
Subject and code is already hard but there is no need to make readers ask unnecessary questions.
This commit is contained in:
Mustafa Kemal Tuna 2020-07-23 13:51:13 +03:00 committed by GitHub
parent f38eb4e1b1
commit 8f3831be1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -33,7 +33,9 @@ We can check it like this:
let obj = {};
alert(obj.__proto__ === Object.prototype); // true
// obj.toString === obj.__proto__.toString == Object.prototype.toString
alert(obj.toString === obj.__proto__.toString); //true
alert(obj.toString === Object.prototype.toString); //true
```
Please note that there is no more `[[Prototype]]` in the chain above `Object.prototype`: