|
Don't use a XHTML doctype if you're not going to even try to write actual XHTML. The body tag isn't option in XHTML, you have to set the namespace, have to escape <, and document.write isn't supported in XHTML for reasons that should be very obvious if you think about how it and XML work. All you have to do is generate all but the last die roll in the loop, then do the last one outside the loop and print everything out how you are.
|
# ¿ Feb 8, 2009 07:12 |
|
|
# ¿ May 4, 2024 07:19 |
|
fletcher posted:Is there any performance difference between using arrays vs. using JSON? Err... JSON is the serialized form of javascript arrays (and objects, strings, etc.). Unless you're doing something insane like directly working with it in string form rather than serializing and deserializing it, your question makes no sense.
|
# ¿ Feb 26, 2009 21:10 |
|
What that statement is doing should be instantly obvious if you have any understanding of how javascript objects work. It's stupid to do things in a way other than the absolutely most basic when the "benefit" is that you save typing 15 characters, but it really shouldn't cause confusion.
|
# ¿ Apr 22, 2009 13:33 |
|
RussianManiac posted:is there any sycnrhonizatino in javacsript? Do most browsers implement pure user level threads for JS or do some of them actually might execute in parallel?
|
# ¿ Jan 2, 2010 02:00 |
|
The mouseover event works correctly for the blue (but not the black) lines for me with Opera 10.50. The click event works for both types of lines.
|
# ¿ Mar 10, 2010 04:22 |
|
It doesn't actually "work" in any browser; it's just that trying to navigate to something that can't possibly be interpreted as a URL results in nothing happening, which is what the author presumably wanted anyway. The only difference is that Firefox complains more visibly about the error.
|
# ¿ Dec 3, 2010 01:10 |
|
Yes, that's absolutely valid (if ill-advised); the expression just has to evaluate to a string (or thing that can be converted to a string), which function() { return false; } does not.
|
# ¿ Dec 3, 2010 01:57 |
|
geeves posted:I admit I don't like the way it looks. Perhaps because I would never do that in Java.
|
# ¿ Jan 5, 2011 06:48 |
|
document.write also isn't supported in xhtml, although I suppose you're obviously serving the page as html as it isn't well-formed xml either.
|
# ¿ Jan 14, 2011 17:33 |
|
Not really. Polling is a bit less fragile, but that's basically the same idea. WebSockets make duplex communication possible, but won't be a realistic option any time soon.
|
# ¿ Jun 11, 2011 01:20 |
|
Your question would be a lot easier to answer if you gave some indication of what results is.
|
# ¿ Jul 30, 2011 00:26 |
|
I assume it was initially a placeholder name that never got changed, since the alternative is just too dumb.
|
# ¿ Mar 11, 2012 21:49 |
|
A closure only has to be formed when a function outlives its upvalues' scopes. In the specific case of Javascript, since functions are the only scoping mechanism, conceptually closures only have to be created when returning from functions (and the function is either being returned or has been stored in a variable in a surviving scope). In practice, I'd expect most implementations to create the closure at the same time as the instantiation of the anonymous function.
|
# ¿ Apr 18, 2012 18:51 |
|
Gnack posted:Because it's clearer. Labelling data just makes sense, I'm surprised this is at all controversial.
|
# ¿ Jul 10, 2012 18:38 |
|
Mogomra posted:Is it even really a "feature" as much as it was one browser assuming that people writing JavaScript are mouth-breathing sub-humans, and then every other browser thinking they needed to do that too or else they'd break the internet?
|
# ¿ Dec 13, 2012 15:28 |
|
Jabor posted:I have no idea why anyone would need sub-cent precision for a POS terminal. Does anyone actually care that they end up paying $15/item instead of $14.995 when they get nominally 50% off?
|
# ¿ Feb 10, 2013 06:54 |
|
I thought CoffeeScript was dumb, then I actually worked on a project that uses it and discovered that it cuts the line count in half while making code significantly more readable. I can't really imagine ever choosing to use pure JS over it for a non-toy project.
|
# ¿ Apr 18, 2013 03:57 |
|
Mogomra posted:I was bored, and what the heck else do you use String.Empty for?
|
# ¿ Aug 2, 2013 17:50 |
|
Wheany posted:I get that you're not serious. That said, aren't strings in C# immutable, like in Java and Javascript? And because of that, don't Java string literals get translated into static code and every instance of a particular string literal is the same instance? Is that not the case in C#? You used to be able to change the value of string.Empty via reflection, but not the value of "". Barring stupid shenanigans like that, they do compile to the same thing (after the JIT gets to it; the IL is different).
|
# ¿ Aug 2, 2013 18:57 |
|
IE10 is significantly faster at basically everything than IE8/9, so that part is totally normal. SVG rendering being faster with the dev tools open is weird, though.
|
# ¿ Aug 13, 2013 04:45 |
|
Just use PHP if you really want to write PHP.
|
# ¿ Aug 21, 2013 01:29 |
|
Ethereal posted:I'm a big fan of the Mocha framework with Chai matchers. Are there even any other realistic options? Mocha+Chai+Sinon seems to be what everyone uses.
|
# ¿ Aug 25, 2013 05:01 |
|
TypeScript'a a superset of Javascript, so trying to use it to avoid learning JS would be rather foolish. It's one of the better compiles-to-JS langauge, and if you're writing a lot of JS and don't like CoffeeScript-style languages I would strong recommend it.
|
# ¿ Sep 3, 2013 16:02 |
|
Where does this whole "I don't want to learn JS" perception come from? I know JS well, and that's why I don't want to use it given other options. ClosureScript and Dart are the only compiles-to-JS language I've seen that even pretend to try to be usable by someone who doesn't already know JS.
|
# ¿ Sep 3, 2013 19:29 |
|
You don't have any chained ifs there. Only the last condition failing will result in the form not submitting, not any of them but the first.
|
# ¿ Sep 27, 2013 01:10 |
|
I have come to dread doing anything involving Google APIs or Google libraries. They're frequently shockingly bad, and when they aren't, the documentation is.
|
# ¿ Oct 16, 2013 03:38 |
|
The problem with that approach is it creates a new copy of each function for each instance of the class, which massively increases memory usage. From a design perspective I'm a fan since it means you get private variables, but it just doesn't scale very well.
|
# ¿ Oct 23, 2013 03:24 |
|
No, it is impossible. That is why none of the libraries written in JS actually work.
|
# ¿ Nov 8, 2013 06:11 |
|
Misogynist posted:Opera's been WebKit-based for awhile now - where are you afraid of it falling behind? Opera 12, not the entirely unrelated blink-based browser.
|
# ¿ Mar 24, 2014 20:05 |
|
Doc Hawkins posted:my experience was that the integration with the javascript ecosystem was essentially absent.
|
# ¿ Mar 26, 2014 21:37 |
|
Strong Sauce posted:It's not recommended to use AppCache. Completely unusable. http://alistapart.com/article/application-cache-is-a-douchebag Did you actually read that article, or did you just laugh at the introduction then close the page? It doesn't actually try to claim that AppCache is unusable; merely that it has a bunch of gotchas you have to keep in mind.
|
# ¿ Jun 9, 2014 03:33 |
|
You're assigning to textures[i] rather than textures[i].texture. Also, use {}, not new Object().
|
# ¿ Jun 13, 2014 16:30 |
|
Chenghiz posted:Why is it that every new hot database seems to be key/value? Are relational databases like postgresql and mssql just that perfected/done?
|
# ¿ Jul 14, 2014 14:11 |
|
Math.random is about as far from a CRNG as you can get. It's sometimes even worse than return 2; as it's sometimes an easy to predict PRNG that leaks state between pages.
|
# ¿ Jul 23, 2014 14:52 |
|
My general experience with things (not in JS) that try to magically handle HATEAOSy APIs is that they don't end up doing anything useful. The lack of standards means that unless you're designing the API to fit what the library wants, configuring the library is at least as much work as just rolling something yourself would be, and you probably can't get away with eagerly fetching the graph (since that may involve a very large number of requests), so all you really want is some helper methods to make it easy to resolve links.
|
# ¿ Jul 23, 2014 17:27 |
|
necrotic posted:The main difference between Javascript's arguments and other languages is that arguments a) contains all of the passed arguments and b) is not actually an array. Any other language I can think of that supports variable argument definitions has both an explicit way of defining access to them (*args in ruby) and the list of variable arguments is not some special "object".
|
# ¿ Aug 16, 2014 20:27 |
|
The whole point of lodash is to be underscore but better, so I'm not sure what could be surprising about the website focusing on how it's better than underscore.
|
# ¿ Sep 18, 2014 17:07 |
|
I sometimes wish that jashkenas was the sort of person to get bored with projects and move on to other things once other people are contributing. He has a pretty solid track record at creating useful new things, but is much worse as a maintainer of things people depend on.
|
# ¿ Sep 18, 2014 19:07 |
|
|
# ¿ May 4, 2024 07:19 |
|
Wheany posted:I really dislike when frameworks do "cute" stuff like that without immediately explaining what they're doing behind the scenes. For me the key thing is if it's immediately obvious that they're doing something cute when reading code using it. It doesn't matter how well documented something is if the code doesn't give me any reason to think I need to look at the documentation. IMO the Chai example is pointlessly clever, but it's not something I'm going to blow four hours on trying to figure out why some perfectly ordinary operation isn't working before discovering that it's because of well-hidden magic.
|
# ¿ Nov 12, 2014 06:47 |