[openstack-dev] [horizon] function expressions vs function declarations in JavaScript

Matthew Farina matt at mattfarina.com
Wed Jan 14 20:19:33 UTC 2015


Thai, I'm still poking around at JavaScript things and did a little testing
on function declarations vs function expressions. Seems Firefox is faster
with function expressions by quite a bit at parse time. For reference see
http://jsperf.com/mfer-function-types.

I'm not suggesting what we do. I'm just sharing a data point I found
surprising.

I'm curious about the process for proposing changes to
https://wiki.openstack.org/wiki/Horizon/Javascript. Is there any process?


On Wed, Jan 14, 2015 at 1:15 PM, Thai Q Tran <tqtran at us.ibm.com> wrote:

>
> It was definitely an interesting the read, I never really noticed the
> subtle difference. Since then I have also read a few other thoughts on it.
> For me, function declarations can get convoluted very fast if not use
> correctly.
> Surely, you should never define functions inside of an if statement, and
> quite confusing to do it after a return statement.
> But they do have their uses when used correctly.
> I think it ultimately depends on what you are trying to do and whether it
> make sense to use declarations vs expressions.
> As long as people understand the difference, and take it case-by-case, its
> not really something I'm going to mull over too much.
>
> -----Matthew Farina <matt at mattfarina.com> wrote: -----
> To: "OpenStack Development Mailing List (not for usage questions)" <
> openstack-dev at lists.openstack.org>
> From: Matthew Farina <matt at mattfarina.com>
> Date: 01/14/2015 07:04AM
> Subject: [openstack-dev] [horizon] function expressions vs function
> declarations in JavaScript
>
>
> JavaScript has multiple ways to deal with functions. There are function
> declarations and function expressions (and named function expressions).
>
> In looking at some reviews and the current code I found some
> inconsistencies which leads me to ask, is there any guidance for handling
> this in Horizon? I noticed no documentation in
> https://wiki.openstack.org/wiki/Horizon/Javascript.
>
> Thanks,
> Matt
>
>
> __________________________________________________________________________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
> __________________________________________________________________________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20150114/6ef9d4d6/attachment.html>


More information about the OpenStack-dev mailing list