Skip to content

Files

Latest commit

 

History

History
19 lines (13 loc) · 448 Bytes

prefer-reflect-apply.md

File metadata and controls

19 lines (13 loc) · 448 Bytes

Pattern: Use of .apply() method call

Issue: -

Description

Using Reflect.apply() is clearer and safer than the .apply() method, which might be overridden or not exist. Reflect.apply() provides a more reliable way to call functions with a given this value and arguments.

Examples

Example of incorrect code:

foo.apply(null, [42]);

Example of correct code:

Reflect.apply(foo, null, [42]);