Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

$.type is deprecated #3747

Open
melloware opened this issue Sep 5, 2021 · 2 comments
Open

$.type is deprecated #3747

melloware opened this issue Sep 5, 2021 · 2 comments

Comments

@melloware
Copy link

melloware commented Sep 5, 2021

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".

@blueimp blueimp closed this as completed Sep 25, 2021
@blueimp blueimp reopened this Sep 25, 2021
@blueimp
Copy link
Owner

blueimp commented Sep 25, 2021

Sorry, I closed this in error thinking that it relates to #3666, which is however a slightly different problem.

In any way, thanks for your report!
I'm still considering if I will support newer jQuery versions at all, but I'll leave this open for now.

@melloware
Copy link
Author

@blueimp no problem I just wanted you aware. I think it will be remove entirely in Jquery 4.0 I have removed it everywhere in my projects for the above Vanilla JS just to make our code forward and backward compatible. Thanks for your consideration!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants