So in the end, it doesn't really matter that much as the React bug 
mentioned in the article was fixed? And there are no "elegant" ways of 
defining a double (e.g. let x = 0.0;) unless you use something 
like 0.000001, Number.MIN_VALUE, -0, or Infinity?

tirsdag 2. juni 2020 12.58.22 UTC+2 skrev Mathias Bynens følgende:
>
> See https://v8.dev/blog/react-cliff:
>
>    - Always initialize your objects in the same way, so that shapes can 
>    be effective.
>    - Choose sensible initial values for your fields to help JavaScript 
>    engines with representation selection.
>
>
> On Tue, Jun 2, 2020 at 12:43 PM <[email protected] <javascript:>> 
> wrote:
>
>> I read an article from 2012 that says V8 tags variables as types 
>> internally: 
>> https://www.html5rocks.com/en/tutorials/speed/v8/#toc-topic-numbers
>>
>> Should I add hints for the optimizer to type in the constructor of a 
>> class if it's going to be used as either a float, integer, boolean or array 
>> respectively later on? By later on I mean used in an initializer function 
>> or something.
>>
>> class Foo {
>>     constructor() {
>>         this.x = 0.0; // double
>>         this.y = 0; // int
>>         this.z = true; // boolean
>>         this.w = []; // array
>>     }
>> }
>>
>> -- 
>> -- 
>> v8-dev mailing list
>> [email protected] <javascript:>
>> 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 [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/v8-dev/30838539-cae5-41e9-9693-e9f4a472aa6e%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/v8-dev/30838539-cae5-41e9-9693-e9f4a472aa6e%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
-- 
v8-dev mailing list
[email protected]
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-dev/86ee67e2-c8d3-40c2-b16c-d05622ced65d%40googlegroups.com.

Reply via email to