Subj : can't understand difference in vars To : johny5@ngs.ru From : Brendan Eich Date : Tue Mar 23 2004 11:36 am You want this instead: JSBool MakeThree(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { return JS_NewNumberValue(cx, 3, rval); } As Marcello's followup points out, the internal representation of 3 should be an int jsval, not a double jsval. Calling JS_NewDouble to make a jsdouble allocated on the GC heap, just to contain a small integer, is wasteful, besides not resulting in the desired operation. Always use JS_NewNumberValue, as it can optimize numbers into ints instead of doubles where possible. /be .