{"json_modified": "2015-05-14T14:38:40.811079", "slug": "Web/JavaScript/Equality_comparisons_and_sameness", "tags": [], "locale": "pt-BR", "title": "Compara\u00e7\u00f5es de igualdade e uniformidade", "translations": [{"title": "Equality comparisons and sameness", "url": "/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness", "tags": ["Sameness", "Intermediate", "JavaScript", "Comparison", "equality"], "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-02-11T05:51:30", "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": ["Sameness", "Intermediate", "JavaScript", "Comparison", "equality"], "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-05-05T07:00:44", "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", "Intermediate", "JavaScript", "Comparison", "equality"], "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 (trict 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": "2014-06-07T01:51:23", "review_tags": []}, {"title": "JavaScript \u4e2d\u7684\u76f8\u7b49\u6027\u6bd4\u8f83", "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-04-30T00:35:30", "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": []}], "modified": "2015-05-14T14:38:37", "label": "Compara\u00e7\u00f5es de igualdade e uniformidade", "localization_tags": ["inprogress"], "url": "/pt-BR/docs/Web/JavaScript/Equality_comparisons_and_sameness", "last_edit": "2015-05-14T14:38:27", "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.", "sections": [{"id": "Quick_Links", "title": "JavaScript Tutorials: JavaScript Guide Introduction Grammar and types Control flow and error handling Loops and iteration Functions Expressions and operators Numbers and dates Text formatting Regular expressions Indexed collections Keyed collections Working with objects Details of the object model Iterators and generators Meta programming Introductory JavaScript basics JavaScript technologies overview Introduction to Object Oriented JavaScript Intermediate A re-introduction to JavaScript JavaScript data structures Equality comparisons and sameness Closures Advanced Inheritance and the prototype chain Strict mode JavaScript typed arrays Memory Management Concurrency model and Event Loop References: Built-in objects Objetos Globais Array ArrayBuffer Boolean [Translate] DataView [Translate] Date Error [Translate] EvalError [Translate] Float32Array [Translate] Float64Array [Translate] Function Generator [Translate] GeneratorFunction [Translate] Infinity Int16Array [Translate] Int32Array [Translate] Int8Array [Translate] InternalError [Translate] Intl [Translate] Intl.Collator [Translate] Intl.DateTimeFormat [Translate] Intl.NumberFormat [Translate] Iterator [Translate] JSON Map [Translate] Math NaN Number Object ParallelArray [Translate] Promise Proxy [Translate] RangeError [Translate] ReferenceError [Translate] Reflect [Translate] RegExp SIMD [Translate] SIMD.float32x4 [Translate] SIMD.float64x2 [Translate] SIMD.int16x8 [Translate] SIMD.int32x4 [Translate] SIMD.int8x16 [Translate] Set StopIteration [Translate] String Symbol SyntaxError [Translate] TypeError [Translate] TypedArray [Translate] URIError [Translate] Uint16Array [Translate] Uint32Array [Translate] Uint8Array [Translate] Uint8ClampedArray [Translate] WeakMap WeakSet [Translate] decodeURI() [Translate] decodeURIComponent() [Translate] encodeURI() [Translate] encodeURIComponent() [Translate] escape() [Translate] eval() isFinite() [Translate] isNaN() null parseFloat() [Translate] parseInt() undefined unescape() [Translate] uneval() [Translate] Expressions & operators Operators Arithmetic operators [Translate] Array comprehensions Assignment operators [Translate] Bitwise operators [Translate] Operador V\u00edrgula Comparison operators [Translate] Operador Condicional Tern\u00e1rio Destructuring assignment [Translate] Expression closures [Translate] Generator comprehensions [Translate] Operador de Agrupamento Legacy generator function expression [Translate] Operadores L\u00f3gicos Object initializer [Translate] Preced\u00eancia de Operadores Property accessors [Translate] Spread operator [Translate] class expression [Translate] delete operator [Translate] function expression [Translate] function* expression [Translate] in operator [Translate] instanceof new operator [Translate] super [Translate] this [Translate] typeof void operator yield [Translate] yield* [Translate] Statements & declarations Statements Legacy generator function [Translate] block [Translate] break class [Translate] const continue [Translate] debugger [Translate] do...while empty [Translate] export [Translate] for [Translate] for each...in [Translate] for...in [Translate] for...of [Translate] function [Translate] function* if...else [Translate] import [Translate] label (Etiqueta) let return [Translate] switch throw [Translate] try...catch var while [Translate] with [Translate] Functions Fun\u00e7\u00f5es Arguments object [Translate] Arrow functions Default parameters [Translate] Method definitions [Translate] Rest parameters [Translate] getter [Translate] setter [Translate] Classes Classes [Translate] constructor [Translate] extends [Translate] static [Translate] Misc Lexical grammar JavaScript data structures Enumerability and ownership of properties Iteration protocols Strict mode Transitioning to strict mode Template strings Deprecated features New in JavaScript New in JavaScript ECMAScript 5 support in Mozilla [Translate] Suporte ao ECMAScript 6 na Mozilla ECMAScript 7 support in Mozilla [Translate] Firefox JavaScript changelog [Translate] New in JavaScript 1.1 [Translate] New in JavaScript 1.2 [Translate] New in JavaScript 1.3 [Translate] New in JavaScript 1.4 [Translate] New in JavaScript 1.5 [Translate] New in JavaScript 1.6 [Translate] New in JavaScript 1.7 [Translate] New in JavaScript 1.8 [Translate] New in JavaScript 1.8.1 [Translate] New in JavaScript 1.8.5 [Translate] Documentation: Useful lists All pages index Methods index Properties index Pages tagged \"JavaScript\" Contribute JavaScript doc status The MDN project"}, {"id": "Igualdade_estrita_usando_.3D.3D.3D", "title": "Igualdade estrita usando ==="}, {"id": "Igualdade_ampla_usando_.3D.3D", "title": "Igualdade ampla usando =="}, {"id": "Igualdade_de_mesmo_valor", "title": "Igualdade de mesmo valor"}, {"id": "Igualdade_abstrata.2C_igualdade_estrita.2C_e_de_mesmo_valor_na_especifica.C3.A7.C3.A3o", "title": "Igualdade abstrata, igualdade estrita, e de mesmo valor na especifica\u00e7\u00e3o"}, {"id": "Um_modelo_para_a_compreens.C3.A3o_compara.C3.A7.C3.B5es_de_igualdade.3F", "title": "Um modelo para a compreens\u00e3o compara\u00e7\u00f5es de igualdade?"}, {"id": "Quando_usar_Object.is_ao_inv.C3.A9s_de_tr.C3.AAs_iguais", "title": "Quando usar Object.is ao inv\u00e9s de tr\u00eas iguais"}, {"id": "Veja_tamb.C3.A9m", "title": "Veja tamb\u00e9m"}], "id": 149915, "review_tags": []}