From ea81831fb358e5917dcad507a74288418e31c87b Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 15 Oct 2014 15:15:08 -0700 Subject: [PATCH] More comments. --- src/compiler/checker.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e0b565cab03..f4f26fa4a3f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4099,6 +4099,12 @@ module ts { // This is motivated by ECMA-262 sections 9.3.1, 9.8.1, 11.1.5, and 11.2.1. // // Here, we test whether 'ToString(ToNumber(name))' is exactly equal to 'name'. + // The '+' prefix operator is equivalent here to applying the abstract ToNumber operation. + // Applying the 'toString()' method on a number gives us the abstract ToString operation on a number. + // + // Note that this accepts the values 'Infinity', '-Infinity', and 'NaN', and that this is intentional. + // This is desired behavior, because when indexing with them as numeric entities, you are indexing + // with the strings '"Infinity"', '"-Infinity"', and '"NaN"' respectively. return (+name).toString() === name; }