Skip to content

Commit 8fb7f46

Browse files
committed
Add accurate comment to the 'equal' function
1 parent 012a455 commit 8fb7f46

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

select2.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,10 @@ the specific language governing permissions and limitations under the Apache Lic
132132
if (a === b) return true;
133133
if (a === undefined || b === undefined) return false;
134134
if (a === null || b === null) return false;
135-
if (a.constructor === String) return a+'' === b+''; // IE requires a+'' instead of just a
136-
if (b.constructor === String) return b+'' === a+''; // IE requires b+'' instead of just b
135+
// Check whether 'a' or 'b' is a string (primitive or object).
136+
// The concatenation of an empty string (+'') converts its argument to a string's primitive.
137+
if (a.constructor === String) return a+'' === b+''; // a+'' - in case 'a' is a String object
138+
if (b.constructor === String) return b+'' === a+''; // b+'' - in case 'b' is a String object
137139
return false;
138140
}
139141

0 commit comments

Comments
 (0)