What string console && (typeof console.log === "function") && console.log('contains called'); is doing in this function:
(function ($) {
$.validator.addMethod('contains', function (value, element, param) {
console && (typeof console.log === "function") && console.log('contains called');
if (this.optional(element)) { return true; } // let required rule deal with this.
var pattern = new RegExp('' + param, "gi");
return value && ('' + value).match(pattern);
}, "Part of the word is invalid");
$.validator.unobtrusive.adapters.add('contains', function (options) {
var element = options.element,
message = options.message;
options.rules['contains'] = $(element).attr('data-val-contains-word');
if (options.message) {
options.messages['contains'] = options.message;
}
});
})(jQuery);
I would understand if that string was like:
var var1 = console && (typeof console.log === "function") && console.log('contains called');
or like: if(console && (typeof console.log === "function") && console.log('contains called'))
It's not a buggy code. It's working.