From 15748e871ea7e12906e7c5ace8aabc2f5f5efa95 Mon Sep 17 00:00:00 2001 From: KaiYu Feng Date: Fri, 1 May 2020 00:14:45 +0800 Subject: [PATCH] fix(docs/mapping-types): fix wrong demo code. get index before push, so the access of this index won't beyond the boundery. --- docs/types/mapping-types.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/types/mapping-types.rst b/docs/types/mapping-types.rst index f69d25b0f..d84da8ec5 100644 --- a/docs/types/mapping-types.rst +++ b/docs/types/mapping-types.rst @@ -138,8 +138,8 @@ the ``sum`` function iterates over to sum all the values. if (keyIndex > 0) return true; else { - self.keys.push(); keyIndex = self.keys.length; + self.keys.push(); self.data[key].keyIndex = keyIndex + 1; self.keys[keyIndex].key = key; self.size++;