{"json_modified": "2016-03-17T13:26:10.574938", "slug": "Web/JavaScript/Equality_comparisons_and_sameness", "tags": ["JavaScript", "Intermedio", "SameValue", "SameValueZero", "igualdad", "Comparaci\u00f3n", "Identidad"], "locale": "es", "title": "Comparadores de igualdad e identidad", "translations": [{"title": "Equality comparisons and sameness", "url": "/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness", "tags": ["SameValueZero", "SameValue", "Equality", "Comparison", "Sameness", "JavaScript", "Intermediate"], "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": "2016-01-05T03:02:12", "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", "Comparison", "Sameness", "JavaScript", "Intermediate"], "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": "2016-01-05T03:46:33", "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", "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": ["\u76f8\u7b49", "JavaScr", "\u6bd4\u8f83", "\u540c\u503c\u76f8\u7b49"], "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": "2016-02-03T03:51:44", "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": []}, {"title": "Equality comparisons and sameness", "url": "/nl/docs/Web/JavaScript/Equality_comparisons_and_sameness", "tags": ["Gelijk", "Vergelijking", "JavaScript"], "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": ["inprogress"], "locale": "nl", "last_edit": "2015-09-11T03:40:00", "review_tags": []}, {"title": "\u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f", "url": "/ru/docs/Web/JavaScript/Equality_comparisons_and_sameness", "tags": ["\u0421\u0440\u0435\u0434\u043d\u0438\u0439", "\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435", "\u0420\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e"], "summary": "\u0412 \u043e\u0431\u0449\u0438\u0445 \u0447\u0435\u0440\u0442\u0430\u0445, \u0434\u0432\u043e\u0439\u043d\u043e\u0435 \u0440\u0430\u0432\u043d\u043e \u043f\u0435\u0440\u0435\u0434 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435\u043c \u0432\u0435\u043b\u0438\u0447\u0438\u043d \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432; \u0442\u0440\u043e\u0439\u043d\u043e\u0435 \u0440\u0430\u0432\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b \u0431\u0435\u0437 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u044f (\u0435\u0441\u043b\u0438 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432, \u0432\u0435\u0440\u043d\u0435\u0442 false
, \u0434\u0430\u0436\u0435 \u043d\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044f); \u043d\u0443 \u0438 Object.is
\u0432\u0435\u0434\u0435\u0442 \u0441\u0435\u0431\u044f \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u0442\u0440\u043e\u0439\u043d\u043e\u0435 \u0440\u0430\u0432\u043d\u043e, \u043d\u043e \u0441\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0434\u043b\u044f NaN
, -0
\u0438 +0
, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u00a0false
\u043f\u0440\u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438\u00a0 -0
\u0438 +0
, \u0438 true
\u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 Object.is(NaN, NaN)
. (\u0412 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u0434\u0432\u043e\u0439\u043d\u043e\u0435 \u0438\u043b\u0438 \u0442\u0440\u043e\u0439\u043d\u043e\u0435 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e \u0432\u0435\u0440\u043d\u0443\u0442 false
\u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443 IEEE 754.) \u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u0441\u0435 \u044d\u0442\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u044b \u043b\u0438\u0448\u044c \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043e\u0432. \u0414\u043b\u044f \u043b\u044e\u0431\u044b\u0445 \u043d\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 x
\u0438 y
, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u0434\u0432\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 (\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 x
\u0438 y
\u043d\u0435 \u0441\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043e\u0431\u044a\u0435\u043a\u0442), \u0432\u0441\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0432\u0435\u0440\u043d\u0443\u0442 false
.", "localization_tags": [], "locale": "ru", "last_edit": "2016-01-01T05:43:05", "review_tags": ["editorial"]}], "modified": "2016-03-17T13:26:07", "label": "Comparadores de igualdad e identidad", "localization_tags": [], "url": "/es/docs/Web/JavaScript/Equality_comparisons_and_sameness", "last_edit": "2016-03-17T13:26:01", "summary": "Explic\u00e1ndolo de manera concisa, un doble igual lleva a cabo una conversi\u00f3n de tipo (cast) cuando se comparan dos cosas; el triple igual hace lo mismo pero sin realizar ninguna conversi\u00f3n de tipo (cast) (simplemente devuelve falso si los tipos de los elementos a comparar son diferentes); Y Object.is funciona de la misma manera que el triple igual pero hace una gesti\u00f3n especial de NaN, -0 y +0 de tal manera que los dos \u00faltimo no son\u00a0 iguales mientras que Object.is(NaN, Nan) nos devolver\u00e1 true
. (Si comparamos NaN con NaN de manera ordinaria , por ejemplo usando el doble igual o el triple igual, nos devolver\u00e1 false
, ya que la especificaci\u00f3n IEEE 754 as\u00ed lo dice). Hay que darse cuenta de que la distinci\u00f3n entre todas estas posibilidades\u00a0 tiene que ver con c\u00f3mo se manejan los los tipos primitivos; ninguna de ellos compara si los par\u00e1metros son similares en relaci\u00f3n a su estructura. Para comparar dos objectos primitivos , x ey, que tengan la misma estructura pero que sean objetos diferentes entre ellos, todos los casos anteriormente descritos devolver\u00e1n false.", "sections": [{"id": "Quick_Links", "title": null}, {"id": "Igualdad_Estricta_usando", "title": "Igualdad Estricta usando\u00a0 "}, {"id": "Igualdad_d\u00e9bil_usando", "title": "Igualdad d\u00e9bil usando\u00a0 =="}, {"id": "Igualdad_Same-value", "title": "Igualdad Same-value"}, {"id": "Igualdad_Same-value-zero", "title": "Igualdad Same-value-zero"}, {"id": "Igualdad_abstracta_igualdad_estricta_e_igualdad_same_value_en_la_especificaci\u00f3n.", "title": "Igualdad abstracta, igualdad estricta e igualdad same value en la especificaci\u00f3n."}, {"id": "\u00bf_Un_modelo_para_comprender_las_comparacions_de_igualdad", "title": "\u00bf Un modelo para comprender las comparacions de igualdad?"}, {"id": "Cuando_usar_Object.is_o_el_igual_triple", "title": "Cuando usar\u00a0"}, {"id": "Ver_adem\u00e1s", "title": "Ver adem\u00e1s"}], "id": 174269, "review_tags": []}