Ah, I didn't pay attention to the "const" there. Yes, those are in the
"script context" rather than the global context. Easiest way to get it is
probably just to evaluate the string "K" and read the result.

Something like:

Local<v8::String> K_source = v8::String::NewFromUtf8(isolate, "K");
Local<v8::Script> K_script = v8::Script::Compile(context,
source).ToLocalChecked();
Local<v8::Value> K_val = K_script->Run(context).ToLocalChecked();
Local<v8::Object> K = Local<v8::Object>::Cast(K_val);

On Sat, Jul 4, 2020 at 12:35 PM <orengavr...@gmail.com> wrote:

> Yes , with var k its works :-)
>
> Any idea how i can get properties of const / let ?
> Which object hold them ?
> i try to retrieve from context without succeess
>
> Thanks a lot
> Oren
>
> On Friday, July 3, 2020 at 5:56:54 PM UTC+3, Marja Hölttä wrote:
>>
>> "const" doesn't define a property in the global object. Does it work if
>> you use "var K" instead of "const K"?
>>
>>
>> On Fri, Jul 3, 2020, 12:02 <oreng...@gmail.com> wrote:
>>
>>> I compile & run this string  "const K = {a: 1, b: 2}; "
>>>>> But when I try to get properties of object K  ,  I got *undefined *at
>>>>> val_k , Any idea why ?
>>>>>
>>>>> v8::Local<v8::Object> global_obj = m_Context->Global();
>>>>> Local<Value> val_k = global_obj->Get(m_Context,
>>>>> v8::String::NewFromUtf8(m_Isolate, "K")).ToLocalChecked();
>>>>>
>>>>> Attached sample that reproduce it
>>>>>
>>>>> Thanks
>>>>> Oren
>>>>>
>>>> --
>>> --
>>> v8-dev mailing list
>>> v8-...@googlegroups.com
>>> http://groups.google.com/group/v8-dev
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "v8-dev" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to v8-...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/v8-dev/5610ff0d-acc1-4d95-9b91-272301386307o%40googlegroups.com
>>> <https://groups.google.com/d/msgid/v8-dev/5610ff0d-acc1-4d95-9b91-272301386307o%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> --
> v8-dev mailing list
> v8-dev@googlegroups.com
> http://groups.google.com/group/v8-dev
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to v8-dev+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/v8-dev/abcefcd3-41a0-4690-9c8f-577d8a7bf525o%40googlegroups.com
> <https://groups.google.com/d/msgid/v8-dev/abcefcd3-41a0-4690-9c8f-577d8a7bf525o%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
-- 
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- 
You received this message because you are subscribed to the Google Groups 
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-dev/CAGRskv8dGp1iPk%3DZMGbfDYpYdyYrYwi4ZYx2n5R8ww-2Dm4LeQ%40mail.gmail.com.

Reply via email to