Wednesday 21 August 2013

jquery Is vs hasClass

The is is multi-purpose, you can for example do is('.class')is(':checked'), etc which means ishas more to do where is hasClass is limited which only checks for a class being set or not.
Hence, hasClass should be faster if performance at any level is your priority.
You can always validate performance on this site as well over multiple browsers: jsperf.com ...These are some test cases to browse: jsperf.com/browse

No comments:

Post a Comment