-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
$.type is deprecated #3747
Description
Using $.type is deprecated according to the jQuery Migration 3.3.2 tool.
See: https://github.com/jquery/jquery-migrate/blob/main/warnings.md#jqmigrate-jquerytype-is-deprecated
Cause: This method returns a string that indicates the type of the argument, for example "number" or "function". However, as the JavaScript language evolves this method has become problematic because new language constructs might require this function to either return a new string (potentially breaking existing code) or somehow map new constructs into existing strings (again, potentially breaking existing code). Examples of new recent JavaScript features include asynchronous functions, class constructors, Symbols, or functions that act as iterators.
Solution: Review code that uses jQuery.type() and use a type check that is appropriate for the situation. For example. if the code expects a plain function, check for typeof arg === "function".