D3sign-Worx

Archive for the ‘Javascript’ Category

Javascript Ternary Operator – more implementation.

Jun 06 2010

Judging by my stats it seems like most people who visit my site seem to be interested in my post on the Javascript Ternary Operator. As a follow up to this I thought I would post another article demonstrating some more uses of the ternary operator.

Read More

Object Orientated javascript

Apr 29 2010

As I stated a few days ago I’ve recently been doing a lot of work with JSON objects to help develop some functionality for prototyping. Whilst I’ve done this I’ve also begun reading Object-Oriented Javascript and I must say I’ve been really impressed with it.

Read More

Javascript Ternary Operator

Feb 14 2010

So just recently at work I was completing some javascript work using the jQuery library; though this post isn’t specific to the jQuery library itself. I’d reached a point in my code where depending on whether a value was above 1 wanted to return “item” or items”. A perfect candidate for the ternary operator I thought. So I put together the following snippet:

item = (val == 1)? "item":"items";

So I fired up firefox,tested a few conditions and everything worked. Just to be on the safe side I loaded up IE7.
To my suprise IE7 was throwing up an error. I thought it was because IE was having difficulting testing a text input value as a number. But after a number of tests and alerts everything was fine. So what was the issue?

Read More