typeof( $("#foo").data("bar") ) will return 'undefined'
On Mar 23, 5:29 pm, I wrote: > I'm using .data to store some information and occasionally hit a case > where I'll try to do something with the stored data and will get an > error e.g., $("#foo").data("bar") is undefined. > > I need to fix my code so that doesn't happen, but would like to know > the best way to test if "bar" has been defined for $("#foo") so that I > can catch these errors before they happen.