All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.javascript.rules.javascript.S6643.html Maven / Gradle / Ivy

There is a newer version: 10.20.0.29356
Show newest version

Prototypes of builtin objects should not be modified.

Why is this an issue?

By default, JavaScript allows you to modify native object prototypes, such as Array, String, Object, and so on. This means you can add new properties or methods to native objects or override existing ones. While this flexibility can be useful in some instances, it can lead to unexpected behavior, bugs, and compatibility issues.

The rule forbids extending or modifying native JavaScript objects or prototypes, as prototypes of builtin objects should not be modified altogether.

Object.prototype.universe = 42;
Object.defineProperty(Array.prototype, "size", { value: 0 });

Resources

Documentation





© 2015 - 2024 Weber Informatics LLC | Privacy Policy