static bool FillMyHashMap(JSContext* cx, MutableHandle<MyHashMap> map) { for (size_t i = 0; i < 10; ++i) { RootedObject obj(cx, JS_NewObject(cx, nullptr)); RootedValue val(cx, UndefinedValue()); // Construct a unique property name to ensure that the object creates a // new shape. char buffer[2]; buffer[0] = 'a' + i; buffer[1] = '\0'; if (!JS_SetProperty(cx, obj, buffer, val)) return false; if (!map.putNew(obj->as<NativeObject>().lastProperty(), obj)) return false; } return true; }