Just a very quick tip about fixing two common mistakes, which would make your JavaScript code throw error in some browsers.
Shame Code 1:
console.log(“log some message”);
Never use a naked console.log()
as you don’t know if the client browser has debug tool or not.
If the client browser is an old version browser or a mobile browser, it may not have a debug tool, in that case, they will get an error!
How to fix it?
Simply check the availability of the console object before using it, improved code:
if (window.console) { console.log("log some message"); }
Shame Code 2:
$ (".fc-event-inner").popover ({
title: ‘title text here’,
trigger : 'hover',
});
Noticed the little highlight comma – ,
behind trigger : 'hover'
?
That misplaced comma in an object or array definition will cause an error in IE browsers, specially in IE 7 browsers, I know lots of people do not care about IE7 any more, but this is a very easy fix to make your code work in all different kinds of browsers, why not fix it?
How to fix it?
If a property setting is the last property in an object or array, make sure you have removed the comma ,
.