TypeScript

TypeScript : Incorrect usage of global object

Overview

ECMAScript provides several global objects. Some of these objects look like constructors, but in fact they are not.Some of these objects look as if they could be constructors due their capitalization (such as Math and JSON) but will throw an error if you try to execute them as functions.

In ECMAScript 5.1, Object.create was added, which enables the creation of objects with a specified [[Prototype]]. Object.create(null) provides a number of methods for working with these prototypes.

If global objects directly use methods from Object.prototype, this can lead to errors.

The following methods are the most dangerous in this case:

  1. hasOwnProperty
  2. isPrototypeOf
  3. propertyIsEnumerable
LOW

DerScanner Severity Score

Check your TypeScript code for this vulnerability, free

Request a free pilot of DerScanner. We give you access and help with the first scan. It works in the cloud and on-premise.

Try it on your code, free

By submitting this form, I acknowledge that DerScanner may process my personal data I provided above for purposes explained above. More details about the processing.