Two way to trim?

Two way to trim?
            $(this).val($.trim($(this).val())); // vs $(this).val().trim();

Someone can explain what is do that both trim first inside and second not?


$.trim is a jQuery method

.trim is standard JavaScript function

They both do the same thing. If you want to use the jQuery version you would write: