43 lines
1.7 KiB
Plaintext

== Why is this an issue?
The types of the arguments that built-in functions accept are specified in the JavaScript language specification. Calls to these functions should conform to the documented types as they are designed to work with specific data types. If the arguments passed to these functions do not match the expected types, it can lead to type errors or unexpected behavior.
Additionally, passing the correct types of arguments to built-in functions can improve performance by reducing the need for type conversions and other operations.
[source,javascript,diff-id=1,diff-type=noncompliant]
----
const isTooSmall = Math.abs(x < 0.0042); // Noncompliant: 'Math.abs' takes a number as argument
----
Ensure that the arguments passed to built-in functions match the documented types. This is an important aspect of writing high-quality, maintainable, and performant code. You can refer to the Mozilla Developer Network (MDN) documentation for the built-in functions. The documentation typically includes information about the expected types of arguments, the return type of the function, and any other relevant details.
[source,javascript,diff-id=1,diff-type=compliant]
----
const isTooSmall = Math.abs(x) < 0.0042;
----
== Resources
=== Documentation
* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects[Global Objects]
* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#type_coercion[Type coercion]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Verify that argument is of correct type: xxx instead of yyy.
=== Highlighting
Argument
endif::env-github,rspecator-view[]