From 8fb7f462979cbef4b5ba69d5d3ece6d22ea2e16f Mon Sep 17 00:00:00 2001 From: Mateusz Dereniowski Date: Thu, 27 Jun 2013 10:26:48 +0200 Subject: [PATCH] Add accurate comment to the 'equal' function --- select2.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/select2.js b/select2.js index b7eb34c3..dc60ba15 100644 --- a/select2.js +++ b/select2.js @@ -132,8 +132,10 @@ the specific language governing permissions and limitations under the Apache Lic if (a === b) return true; if (a === undefined || b === undefined) return false; if (a === null || b === null) return false; - if (a.constructor === String) return a+'' === b+''; // IE requires a+'' instead of just a - if (b.constructor === String) return b+'' === a+''; // IE requires b+'' instead of just b + // Check whether 'a' or 'b' is a string (primitive or object). + // The concatenation of an empty string (+'') converts its argument to a string's primitive. + if (a.constructor === String) return a+'' === b+''; // a+'' - in case 'a' is a String object + if (b.constructor === String) return b+'' === a+''; // b+'' - in case 'b' is a String object return false; }