Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

195
Vistas
Is there an `assert.deepEqual` that uses _non-strict_ equality for JavaScript?

I have reason to test eg. [ { valueOf: ()=>0 } ] to [ 0 ] and want that test to succeed.

Node assert, and Chai's various interfaces, all seem to automatically use strict equality when doing deep equality tests.

Is there an assert.deepEqual that will not do an assert.deepStrictEqual somewhere? A deep analog of assert.equal instead of assert.strictEqual ?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

All right, developing insight: it can't be done generally.

deepEqual will compare "all own and inherited enumerable object properties", and it will ( I am assuming here ) recursively descend on object properties until it encounters primitive values.

It has no reason to stop after the first level ( the array ), when encountering the second level ( the object ). The fact that my data actually has the encoding at the Object level is specific to my use case, and can not be assumed for the general case.

When arriving at primitive values for properties, then equality can generally usefully be non-strict.

The fact that an Object has a valueOf property ( which may or may not even be enumerable ) does not mean it should be treated as a primitive instead of an Object. Lots of things have a valueOf property.

The difference between deepEqual and equal is that equal knows it should be comparing two primitives ( or references ), and deepEqual can never know.

I was assuming too much, and asking the wrong question. Sorry SO.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda