1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-26 03:32:20 +00:00

docs(symbol): edit symbol/Symbol.instanceOf

This commit is contained in:
ruanyf 2017-10-10 11:04:41 +08:00
parent 88248d97c3
commit 1ac918c804

View File

@ -492,6 +492,13 @@ class Even {
}
}
// 等同于
const Even = {
[Symbol.hasInstance](obj) {
return Number(obj) % 2 === 0;
}
};
1 instanceof Even // false
2 instanceof Even // true
12345 instanceof Even // false