{"json_modified": "2015-09-11T03:40:12.188511", "slug": "Web/JavaScript/Equality_comparisons_and_sameness", "tags": ["Gelijk", "Vergelijking", "Javascript", "JavaScript"], "locale": "nl", "title": "Equality comparisons and sameness", "translations": [{"title": "Equality comparisons and sameness", "url": "/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness", "tags": ["Equality", "equality", "Sameness", "JavaScript", "Intermediate", "Comparison"], "summary": "Briefly, double equals will perform a type conversion when comparing two things; triple equals will do the same comparison without type conversion (by simply always returning false if the types differ); and Object.is will behave the same way as triple equals, but with special handling for NaN and -0 and +0 so that the last two are not said to be the same, while Object.is(NaN, NaN) will be true. (Comparing NaN with NaN ordinarily\u2014i.e., using either double equals or triple equals\u2014evaluates to false, because IEEE 754 says so.) Do note that the distinction between these all have to do with their handling of primitives; none of them compares whether the parameters are conceptually similar in structure. For any non-primitive objects x and y which have the same structure but are distinct objects themselves, all of the above forms will evaluate to false.", "localization_tags": [], "locale": "en-US", "last_edit": "2015-08-02T08:49:16", "review_tags": []}, {"title": "Utiliser les diff\u00e9rents tests d'\u00e9galit\u00e9", "url": "/fr/docs/Web/JavaScript/Les_diff%C3%A9rents_tests_d_%C3%A9galit%C3%A9", "tags": ["Equality", "equality", "Sameness", "JavaScript", "Intermediate", "Comparison"], "summary": "En r\u00e9sum\u00e9, l'\u00e9galit\u00e9 faible effectuera une conversion des deux \u00e9l\u00e9ments \u00e0 comparer avant d'effectuer la comparaison, l'\u00e9galit\u00e9 stricte effectuera la m\u00eame comparaison mais sans conversion pr\u00e9alable (elle renverra toujours false si les types des deux valeurs compar\u00e9es sont diff\u00e9rents), enfin Object.is() se comportera comme l'\u00e9galit\u00e9 stricte sauf pour les valeurs NaN, -0 et +0 : pour Object.is(), -0 et +0 seront diff\u00e9rents mais on aura Object.is(NaN, NaN) qui sera true. (G\u00e9n\u00e9ralement, quand on compare NaN avec NaN en utilisant l'\u00e9galit\u00e9 stricte ou l'\u00e9galit\u00e9 faible, cela donne false afin de respecter la norme IEEE 754.). On notera que pour ces trois op\u00e9rations, la comparaison s'effectue sur les valeurs des \u00e9l\u00e9ments qu'on compare, aucune de ces op\u00e9rations ne permet de comparer la structure des param\u00e8tres. Pour des objets non primitifs, x et y qui ont la m\u00eame structure mais qui sont des objets distincs, chacune des op\u00e9rations pr\u00e9sent\u00e9es ci-avant sera \u00e9valu\u00e9e \u00e0 false.", "localization_tags": [], "locale": "fr", "last_edit": "2015-08-03T10:52:24", "review_tags": []}, {"title": "\u7b49\u4fa1\u6027\u306e\u6bd4\u8f03\u3068\u305d\u306e\u4f7f\u3044\u3069\u3053\u308d", "url": "/ja/docs/Web/JavaScript/Equality_comparisons_and_when_to_use_them", "tags": ["Guide", "Equality", "equality", "JavaScript", "Intermediate", "Comparison"], "summary": "JavaScript \u306b\u306f 3 \u7a2e\u985e\u306e\u5024\u6bd4\u8f03\u6f14\u7b97\u5b50\u304c\u3042\u308a\u307e\u3059\u3002=== \u306b\u3088\u308b\u53b3\u683c\u306a\u7b49\u4fa1\u6027 (strict equality)\u3001== \u306b\u3088\u308b\u5bdb\u5bb9\u306a\u7b49\u4fa1\u6027 (loose equality)\u3001Object.is (ECMAScript 6 \u306e\u65b0\u6a5f\u80fd) \u3067\u3059\u3002\u3069\u306e\u6f14\u7b97\u5b50\u3092\u4f7f\u7528\u3059\u308b\u304b\u306f\u3001\u3069\u306e\u3088\u3046\u306a\u6bd4\u8f03\u3092\u884c\u3044\u305f\u3044\u304b\u306b\u4f9d\u5b58\u3057\u307e\u3059\u3002", "localization_tags": [], "locale": "ja", "last_edit": "2015-08-16T00:09:25", "review_tags": []}, {"title": "JavaScript \u4e2d\u7684\u76f8\u7b49\u6027\u5224\u65ad", "url": "/zh-CN/docs/Web/JavaScript/Equality_comparisons_and_sameness", "tags": [], "summary": "\u7b80\u5355\u5730\u8bf4\uff0c\u4e24\u7b49\u53f7\u5224\u7b49\u4f1a\u5728\u6bd4\u8f83\u65f6\u8fdb\u884c\u7c7b\u578b\u8f6c\u6362\uff1b\u4e09\u7b49\u53f7\u5224\u7b49\u4e0d\u4f1a\u8fdb\u884c\u7c7b\u578b\u8f6c\u6362\uff08\u5982\u679c\u7c7b\u578b\u4e0d\u540c\u4f1a\u76f4\u63a5\u8fd4\u56de false \uff09\uff1b Object.is \u5728\u4e09\u7b49\u53f7\u5224\u7b49\u7684\u57fa\u7840\u4e0a\u7279\u522b\u5904\u7406\u4e86 NaN \u3001 -0 \u548c +0 \uff0c\u4fdd\u8bc1 -0 \u548c +0 \u4e0d\u518d\u76f8\u540c\uff0c\u4f46 Object.is(NaN, NaN) \u4f1a\u8fd4\u56de true\u3002\uff08\u50cf\u5176\u4ed6\u6570\u503c\u4e00\u6837\u6bd4\u8f83 NaN \u2014\u2014\u7531\u4e8e IEEE 754 \u7684\u89c4\u8303\uff0c\u65e0\u8bba\u4f7f\u7528\u53cc\u7b49\u53f7\u6216\u4e09\u7b49\u53f7\uff0c\u6bd4\u8f83 NaN \u90fd\u4f1a\u5f97\u5230 false \uff09\u4f46\u8bf7\u6ce8\u610f\uff0c\u6b64\u5916\uff0c\u8fd9\u4e09\u4e2a\u8fd0\u7b97\u7b26\u7684\u539f\u8bed\u4e2d\uff0c\u6ca1\u6709\u4e00\u4e2a\u4f1a\u6bd4\u8f83\u4e24\u4e2a\u53d8\u91cf\u662f\u5426\u7ed3\u6784\u4e0a\u6982\u5ff5\u7c7b\u4f3c\u3002\u5bf9\u4e8e\u4efb\u610f\u4e24\u4e2a\u4e0d\u540c\u7684\u975e\u539f\u59cb\u5bf9\u8c61\uff0c\u5373\u4fbf\u4ed6\u4eec\u6709\u76f8\u540c\u7684\u7ed3\u6784\uff0c \u4ee5\u4e0a\u4e09\u4e2a\u8fd0\u7b97\u7b26\u90fd\u4f1a\u8ba1\u7b97\u5f97\u5230 false \u3002", "localization_tags": [], "locale": "zh-CN", "last_edit": "2015-06-04T02:24:56", "review_tags": []}, {"title": "Vergleiche auf Gleichheit und deren Verwendung", "url": "/de/docs/Web/JavaScript/Vergleiche_auf_Gleichheit_und_deren_Verwendung", "tags": [], "summary": "Kurz gesagt nimmt double equals eine Typkonvertierung der Operanden vor, bevor der Vergleich der Werte gemacht wird. Bei triple equals werden die Werte ohne vorherige Typkonvertierung miteinander verglichen. Wenn sich die Datentypen der beiden Operanden unterscheiden liefert triple equals immer false zur\u00fcck. Object.is verh\u00e4lt sich wie triple equals und bietet dar\u00fcber hinaus eine spezielle Behandlung f\u00fcr NaN und -0 und +0 an. -0 und +0 sind f\u00fcr Object.is ungleich w\u00e4hrend Object.is(NaN, NaN) true ist. Laut IEEE 754 ergibt ein Vergleich von zwei NaN mit double equals oder triple equals false. Diese drei Operationen unterscheiden sich ihrere Behandlung von primitiven Datentypen. Es wird nicht gepr\u00fcft, ob die beiden Operanden konzeptionell diesselbe Struktur besitzen. F\u00fcr die nichtprimitiven Objekte x und y, welche diesselbe Struktur besitzen aber zwei unterschiedliche Objekte sind, ergeben die drei Operationen false.", "localization_tags": [], "locale": "de", "last_edit": "2015-02-14T12:06:00", "review_tags": []}, {"title": "Compara\u00e7\u00f5es de igualdade e uniformidade", "url": "/pt-BR/docs/Web/JavaScript/Equality_comparisons_and_sameness", "tags": [], "summary": "Em resumo, dois iguais ir\u00e1 realizar uma convers\u00e3o de tipo ao comparar duas coisas; tr\u00eas iguais ir\u00e1 fazer a mesma compara\u00e7\u00e3o, sem convers\u00e3o de tipo (simplesmente retornando false se os tipos forem diferentes); e Object.is ir\u00e1 se comportar da mesma forma que tr\u00eas iguais, mas com tratamento especial para NaN e -0 e +0 de modo que os dois \u00faltimos n\u00e3o s\u00e3o referidos como sendo o mesmo, enquanto Object.is(NaN, NaN) ser\u00e1 true. (Comparando NaN com NaN ordinariamente - ou seja, usando tanto iguais duplo ou iguais triplo - avalia como false, porque IEEE 754 diz isso.) Note que a distin\u00e7\u00e3o entre todos eles t\u00eam a ver com seu manuseio dos primitivos; nenhum deles compara se os par\u00e2metros s\u00e3o conceitualmente semelhante em estrutura. Para qualquer objetos n\u00e3o-primitivo x e y que t\u00eam a mesma estrutura, mas s\u00e3o objetos distintos entre si, todas as formas acima ser\u00e1 avaliada como falsa.", "localization_tags": ["inprogress"], "locale": "pt-BR", "last_edit": "2015-05-14T14:38:27", "review_tags": []}], "modified": "2015-09-11T03:40:08", "label": "Equality comparisons and sameness", "localization_tags": ["inprogress"], "url": "/nl/docs/Web/JavaScript/Equality_comparisons_and_sameness", "last_edit": "2015-09-11T03:40:00", "summary": "Briefly, double equals will perform a type conversion when comparing two things; triple equals will do the same comparison without type conversion (by simply always returning false if the types differ); and Object.is will behave the same way as triple equals, but with special handling for NaN and -0 and +0 so that the last two are not said to be the same, while Object.is(NaN, NaN) will be true. (Comparing NaN with NaN ordinarily\u2014i.e., using either double equals or triple equals\u2014evaluates to false, because IEEE 754 says so.) Do note that the distinction between these all have to do with their handling of primitives; none of them compares whether the parameters are conceptually similar in structure. For any non-primitive objects x and y which have the same structure but are distinct objects themselves, all of the above forms will evaluate to false.", "sections": [{"id": "Quick_Links", "title": null}, {"id": "Strict_equality_using", "title": "Strict equality using "}, {"id": "Loose_equality_using", "title": "Loose equality using =="}, {"id": "Same-value_equality", "title": "Same-value equality"}, {"id": "Abstract_equality_strict_equality_and_same_value_in_the_specification", "title": "Abstract equality, strict equality, and same value in the specification"}, {"id": "A_model_for_understanding_equality_comparisons", "title": "A model for understanding equality comparisons?"}, {"id": "When_to_use_Object.is_versus_triple_equals", "title": "When to use "}, {"id": "See_also", "title": "See also"}], "id": 161301, "review_tags": []}