Mostly Bollogs, I'm afraid

But occasionally, a glimmer of truth.
If you find one, please let me know.



Thursday, 16 February 2012

javascript

7. What possibly unintentional behaviour is exhibited in the following code and how would you correct it?

function buildItems() { var i, arr = []; for (i = 0; i < 20; i++) {
arr.push({ item: create(i), kill: function() {
remove(i); }
}); } return arr;
} buildItems()[10].kill();

6 comments:

Anonymous said...

'Kill function'? Wasn't that in Robocop?

CptCoathanger said...
This comment has been removed by the author.
CptCoathanger said...

The final call "buildItems()[10].kill();" will call the remove function with "20" as its parameter, not "10" as you might expect.

Javascript Countdown Timer said...

It is entirely possible to EDIT markup in a textarea. The behavior of HTML entities within a textarea allows for this behavior, but it must be done correctly to be valid. Server-Side Navigation Bar and is the fancy name given to the ring navigation code that is called by a piece of javascript. It is on the page where you copy this piece of javascript that I had the problem of it rendering rather than showing in the textarea.

Cheers!!

livescore said...

Gorgeous dress and lovely fabric choice! Don't be sad about sbo moving to London, think of all the lovely vintage social events you ผลบอลสด can go to. Also London has great fabric shops!

gclub said...

Good website! I really love บาคาร่า how it is easy on my eyes and the data are well written. I’m wondering how I could be notified when a new post has been made. I have subscribed to your RSS which must do the trick! Have a great day!