unexpected token error for catch javascript

I am banging my head trying to find the error in this code. I have checked it so many times can someone point out where the problem is?

$(function() {
  try {
    function endswith(str, ends) {
      if (ends === '') return true;
      if (str == null || ends == null) return false;
      str = String(str);
      ends = String(ends);
      return str.length >= ends.length && str.slice(str.length - ends.length) === ends;
    }
    var referrer = new URL(document.referrer).domain;
    if (endswith(referrer, "xyz.com")) {
      $(".logo .logo-external").remove();
    } else {
      $(".logo .logo-internal").remove();
    }
  } catch () {}
});

Answers


catch (e) {} You missed the variable e

$(function() {
  try {
    function endswith(str, ends) {
      if (ends === '') return true;
      if (str == null || ends == null) return false;
      str = String(str);
      ends = String(ends);
      return str.length >= ends.length && str.slice(str.length - ends.length) === ends;
    }
    var referrer = new URL(document.referrer).domain;
    if (endswith(referrer, "xyz.com")) {
      $(".logo .logo-external").remove();
    } else {
      $(".logo .logo-internal").remove();
    }
  } catch (e) {}
});

Need Your Help

Oracle SQL: rtrim and group by

sql oracle group-by string-aggregation

I was doing like the following query and received "not a single-group group function" error.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.