Este producto no es compatible con el sitio Datadog seleccionado. ().
Esta página aún no está disponible en español. Estamos trabajando en su traducción.
Si tienes alguna pregunta o comentario sobre nuestro actual proyecto de traducción, no dudes en ponerte en contacto con nosotros.

Metadata

ID: javascript-best-practices/no-unused-expressions

Language: JavaScript

Severity: Warning

Category: Performance

Description

This rule in JavaScript ensures that the code you write is actually used. An unused expression is a piece of code that is evaluated but the result is not used or assigned to a variable. These expressions do not have any effect on the program and can lead to confusion, making the code harder to read and understand.

To avoid unused expressions, always ensure that the result of each expression is either assigned to a variable, used in a larger expression, or used as an argument to a function.

Non-Compliant Code Examples

1

if(2) 3

{4}

func(5), {}

foo && bar()

foo, bar()

baz = foo, bar;

foo() && function funcInExpression() {baz();}

(function incompleteIIFE() {});

Compliant Code Examples

{} // This is a block, so it's ok.

function namedFunc() {}

(function realIIFE(){} ());

func()

foo = 1

new Bar

delete foo.baz

void baz
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Integraciones sin problemas. Prueba Datadog Code Security