Archives for February 2009

February 2009 (19)
SMTWTFS
« Jan Mar »
1234567
891011121314
15161718192021
22232425262728

Like this Archive Calendar widget? Download it here.


JavaScript for C# programmers: prototypes and privacy

Continuing my series about learning JavaScript when you're a C# programmer, using Firebug in Firebox as our testing ground. In this episode, overriding, privacy, and class models. Last time we saw how to create inheritance from JavaScript's constructors and prototypes, the so-called prototypal inheritance. In our example, we ended up with this: var Point = function (x , y) { this .x = x; this .y = y; return this ; }; Point.prototype.move = function (x , y) { this .x += x; this .y += y; }; This code...

READ MORE

Party Shuffle Friday

Last week I was travelling, so wasn't able to write up a PSF. This week, though, the guests are back and ready to, er, groove on down. Why Don't We Live Together? , by Pet Shop Boys, from Please . From their first album, so called because they wanted buyers to go into record stores and be polite when they asked for it ("Pet Shop Boys, please"). Or so they say... A nice little song from their early days where the singer is trying to get the person he loves to live with him. Touch Me Now...

READ MORE

JavaScript for C# programmers: prototypes, the basics

Another post in the the series that discusses JavaScript for those more familiar with C#. In this episode, the first of a couple on the topic, we look at prototypes and prototypal inheritance. Despite the fact that the keyword class is reserved, there are no classes in JavaScript as you'd understand them from C#. And, yet, it is an object-oriented programming language: there are objects, after all. It's all made even more confusing since JavaScript has a new keyword. How does it new up an object...

READ MORE

Printer CSS - call to action

Ned Batchelder is a tech blogger I like to read, although he tends to deal with languages and situations I don't. Nevertheless he comes up with some great insights that have applicability to what I do and some great topics that extend what I know. In a recent post , he brought to his readers' attention that good websites should have a proper printer CSS stylesheet, so that their content not only gets rendered well on the screen, but also on paper. Paper being paper, there's no point in rendering...

READ MORE

JavaScript for C# programmers: closure basics

Continuing the series on JavaScript for C# developers, in this episode we look at closure. First the definition. A closure is a function that encloses its local environment when it is created. Now, in C#, the function talked about in the definition above is a lambda expression or an anonymous method . The language definition for C# talks about the outer variables of an anonymous method, these are the local variables and parameters that are in the same scope as the anonymous method (note that this...

READ MORE

Fixing this blog for Internet Explorer 8

As detailed over on my work blog , I installed IE8 RC1 this morning. Because my home page in IE7 was this blog (it is in all my browsers), it was the first thing to come up in IE8. And IE8 immediately flipped into compatibility mode and displayed the page as if it was IE7. To put it mildly, this was both weird and aggravating, since the whole site validates both as XHTML 1.0 transitional and as CSS 2.1. There should have been no problem. Given that the only advice you see (or can find online) on...

READ MORE

JavaScript for C# programmers: void

A very short, sweet post in the series for C# developers learning JavaScript. In this episode, we look into the void . In C#, void is a type that has no values. We talk of a method returning void , when we actually mean the method doesn’t return anything — it’s a procedure and not a function. Well in JavaScript, all functions and methods return something and if you don’t explicitly use the return keyword, the function returns undefined . If you run the following code in Firebug, you’ll get "return...

READ MORE

JavaScript for C# programmers: Truth and falsity

A quick post in the continuing series on programming in JavaScript from a C# developer's perspective. In this episode, we're going to look at truth within boolean and conditional expressions. In C#, you know that when you're constructing some conditional expression for your if statement the expression must evaluate to either true or false. The expression is either a boolean variable or function returning a boolean, or is some kind of comparative expression using other types. You learn...

READ MORE

PCPlus 265: Evaluating expressions

I write a monthly column for PCPlus, a computer news-views-n-reviews magazine in the UK (actually there are 13 issues a year — there's an Xmas issue as well — so it's a bit more than monthly). The column is called Theory Workshop and appears in the back of every issue. When I signed up, my editor and the magazine were gracious enough to allow me to reprint the articles here after say a year or so. After all, the PDFs do appear on each issue's DVD after a couple of months....

READ MORE

Party Shuffle Friday

Another quick iTunes party shuffle. I think the guests at this party will be mightily confused. Wonderful Disguise , by Scott, Mike, from Bring 'em All In . Mike Scott, if you didn't know, is the driving force (only force, really) behind Waterboys. He can be a bit preachy and religious at times, but he doesn't half write some great tunes. This one is one of his "smack you with my faith" tracks, nice and quiet, essentially just him on the guitar, about how he finds God in everyone he sees...

READ MORE