[Info-vax] [OT] The wonders of Javascript...

johnwallace4 at yahoo.co.uk johnwallace4 at yahoo.co.uk
Sun Mar 1 11:13:23 EST 2015


On Sunday, 1 March 2015 14:16:10 UTC, Simon Clubley  wrote:
> [Yes, I know it's OT for comp.os.vms, but I thought some might
> find the following interesting.]
> 
> Due to a mistake (I got distracted), I ran the following line of code
> before adding code to define and initialise resume_offset elsewhere:
> 
> ndm_database[this.db_idx].file_size =
>         conn_database[this.db_idx].channel.contentLength
>         + ndm_database[this.db_idx].resume_offset;
> 
> Turns out that in Javascript integer + undefined variable equals a
> silent NaN and not a syntax error:
> 
> info: ndm: file_size = NaN, contentLength = 72306438, resume_offset = undefined
> 
> Even better, at some point along it's path from the addon script to the
> front end content script (Firefox isolates addon and content scripts
> and requires you to communicate by posting messages between them), the
> NaN had been transformed in a way which rendered the formatted value as
> zero on the front end HTML display instead of as a NaN...
> 
> Oh, the wonders of Javascript (part 482!)...
> 
> As well as adding features which make modern languages nicer to use
> than traditional languages, it would be nice if some modern language
> designers also included the robustness features from traditional
> languages. In no sane language should it be possible to add using an
> undefined variable without generating a syntax error.
> 
> The above info: line was generated by a console.log() statement
> immediately following the above addition and the fact the Javascript
> interpreter even executed the console.log() call after the above error
> instead of aborting execution says a lot about Javascript... :-)
> 
> Simon.
> 
> -- 
> Simon Clubley, clubley at remove_me.eisner.decus.org-Earth.UFP
> Microsoft: Bringing you 1980s technology to a 21st century world

Judging by the mild element of pained surprise, I'm guessing you may
not yet seen Gary Bernhardt's five minute WAT talk from CodeMash 2012.

He starts with Ruby but JS gets a mention fairly soon, and he
continues in the same vein.

The original should be at
https://www.destroyallsoftware.com/talks/wat
but the video there won't play for me right now.

The wayback machine has a copy that works for me:
https://archive.org/details/wat_destroyallsoftware

Five minutes. That's all it'll take if you watch from start to end
uninterrupted. You'll to watch as well as listen, and might want to
be ready on the rewind button.

The wonders of modern technology.

Have a lot of fun.



More information about the Info-vax mailing list