Subj : Re: can't understand difference in vars To : netscape.public.mozilla.jseng From : Marcello Bastea-Forte Date : Tue Mar 23 2004 08:59 am Jashin Eugene wrote: > Ok.. There is 2 variants of code: > > 1: > > var n = 3; > logging(n); > logging(typeof(n)); > switch(n) > { > case 3: > logging("AAA"); > break; > default: > logging("DDD"); > } > > where logging, it just function for output string into log. > Output of this code is "3", "number", "AAA". > > 2: > > var n = MakeThree(); > switch(n) > { > case 3: > logging("AAA"); > break; > default: > logging("DDD"); > } > > where MakeThree defined as: > > JSBool MakeThree(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, > jsval *rval) > { > *rval = DOUBLE_TO_JSVAL( JS_NewDouble(cx, (double)3) ); > return JS_TRUE; > } > > Output of this code is "3", "number", "DDD". > > I don't understand, what's wrong?! > > double and integer types are different... Try making an int in your MakeThree function. Marcello .