javascript - Native function [.sort()] not recognized inside event handler -


environment: seamonkey (firefox 20.0)

i'm trying simple sort: either inside worker or inside postmessage handler.

(all code samples inside top level (.html) file).

works:

function a() {   var xyzzy = [40, 1, 5, 200];   xyzzy.sort(); }; 

fails: (error: typeerror: xyzzy.sort not function)

var lrw0 = new worker('lrw0.js'); lrw0.onmessage = function (event) {   var xyzzy = [40, 1, 5, 200];   xyzzy.sort(); }; 

after postmessage event handler has same context , scope did worker. fair enough. needless sort fails inside worker itself. seems if utility library cannot accessed?

utterly defeated. have spent days on - no doubt reading solution somewhere without having understood it. contributions (including 'rude informative') gratefully accepted. appreciate necessity of mercilessly punishing newbies.

neither of examples work until fix call array.sort method

syntax

array.sort([comparefunction])

javascript

function a() {   var xyzzy = [40, 1, 5, 200];   xyzzy.sort(); // notice difference    console.log(xyzzy); };  a(); 

on jsfiddle


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -