Forum Moderators: open

Message Too Old, No Replies

Checking Javascript warnings

         

toplisek

5:46 am on Sep 13, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have seen many warnings at different websites like:
Reference to undefined property a[c]
[google-analytics.com...]
Line: 11
like:
b,a&&a[o]),a;}}},S=function(a,b,c,d){R[t][a]=function(){try{return F(c),ma(this.a.get(b),d)}catch(e){throw za("exc",a.......

When is this warning shown? Is this wrong js code inside website or it will not detect all code in the start and show warning?

JAB Creations

2:09 pm on Sep 13, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



First off ignore errors in Google's code, they're not going to bother to fix it unless it breaks for them.

Secondly you should adhere to fixing errors in your own code. Firefox has a strict mode and ECMAScript 5 has it's own strict mode; they are not related from what I've read.

You can implement strict mode by using the following...

'use strict';


If you want to restrict it to a specific function put it inside of the function...

function happy() {'use strict';}


Most programmers don't seem to comprehend why fixing strict warnings is beneficial. Server side wise if a hacker is trying to pry for information (such as the reference to a database item) code might give it away by simply not providing an HTTP variable (e.g. $_GET['item1']) and the site might throw an error visible to the hacker. With JavaScript it's a bit less pronounced though I still think coding to a higher level has it's benefits. Even JavaScript can benefit by having a level of fault tolerance. If the site still manages to work in the face of a problem then you will have a much higher chance of retaining visitors. If the error generates too much frustration a visitor might leave your site altogether.

- John

rocknbil

4:22 pm on Sep 13, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You are likely seeing these on site using Jquery or some other library. The root cause is **usually** something in the page referencing it is not implemented properly. One example might be attempting to execute a function in the head of the document that requires a page element that hasn't loaded yet.