Skip to main content
Stack Overflow
  1. About
  2. For Teams

Timeline for javascript var statement and performance

Current License: CC BY-SA 3.0

Post Revisions

14 events
when toggle format what by license comment
Mar 12, 2012 at 19:30 vote accept frenchie
Mar 12, 2012 at 18:47 history edited gdoron CC BY-SA 3.0
deleted 2 characters in body; edited tags
Mar 12, 2012 at 18:47 answer added josh3736 timeline score: 1
Mar 12, 2012 at 18:45 answer added Marshall timeline score: 6
Mar 12, 2012 at 18:43 answer added yas timeline score: 0
Mar 12, 2012 at 18:33 comment added Chad Assigning a value at declaration is significantly faster (see this jsPerf).However whether you use multiple var statements or not, doesn't really matter.
Mar 12, 2012 at 18:33 comment added josh3736 Note that option 1 is not really what you're calling it. There are actually two assignments: once when you declare the variable and assign null to it, then again when you assign SomeValue.
Mar 12, 2012 at 18:30 comment added Ortiga There are so many thing that can impact your performance further, that you shouldn't bother with this... Just do whatever you find easier to read, as this won't impact performance. Plus, it may vary depending on what JS engine you are using.
Mar 12, 2012 at 18:30 answer added Cᴏʀʏ timeline score: 0
Mar 12, 2012 at 18:29 answer added zzzzBov timeline score: 0
Mar 12, 2012 at 18:28 comment added c0deNinja i dunno about performance differences but stylistically i would go with option 3.
Mar 12, 2012 at 18:27 answer added Ayman timeline score: 0
Mar 12, 2012 at 18:26 answer added gdoron timeline score: 17
Mar 12, 2012 at 18:24 history asked frenchie CC BY-SA 3.0

AltStyle によって変換されたページ (->オリジナル) /