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 <matt0stackho...@gmail.com> 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 > 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/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 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/CADizRgYqz5337Lr0bbHA9QQKf5Nt93jH-P2__OG8ZnCjJVLvwg%40mail.gmail.com.