|
Flobbster posted:Awesome, that's exactly the kind of reference I was looking for (and it looks fairly recent which is probably why I never came across it before). Thanks! Crockford's awesome do whatever he tells you.
|
# ¿ Apr 7, 2009 18:27 |
|
|
# ¿ Apr 29, 2024 01:00 |
|
MonkeyMaker posted:OK, I have a JSON object with two sub-objects. How do I reference a sub-object by name, not index? Arrays (using the []) notation, and objects (using {}) are different. Objects can be accessed using the dot notation or as an associative array. Arrays can only have numeric indexes, hence why you can't use ['menus']['buckets']. http://javascript.crockford.com/survey.html has a good explanation.
|
# ¿ Apr 22, 2009 01:13 |
|
There Will Be Penalty posted:That explanation contradicts you. Technically they're a hashtable, yes. I over-generalized a bit to help with the distinction between when you'd want to use arrays vs objects. Never mind that in JS an array is technically just a specialization of an object...
|
# ¿ Apr 22, 2009 04:38 |
|
diadem posted:Thank you so much. This bug was a huge pain. You're just triggering a reflow as far as I can tell, here's a good article about browser reflow. http://www.stubbornella.org/content/2009/03/27/reflows-repaints-css-performance-making-your-javascript-slow/
|
# ¿ May 7, 2009 20:13 |
|
Jreedy88 posted:Yeah, block formatting messed my page design anyways so I ended up just doing a display="none" on the element in javascript after the page had loaded. The answer to your disappeared question is to use "new Date()" instead of just "Date()", fyi.
|
# ¿ Jun 26, 2009 16:40 |
|
dancavallaro posted:What is an example of a use case where it makes sense to use == over ===? Maybe he just really likes type coercion?
|
# ¿ Sep 1, 2010 18:21 |
|
Kekekela posted:parseInt(x) == parseInt(y) You probably want bases on those calls to parseInt or else if the input is something like "08" you aren't going to get the answer you want. Always specify a base for calls to parseInt, seriously.
|
# ¿ Sep 1, 2010 23:01 |
|
Kekekela posted:Thanks for this. Just substitute in "function call returning a specific type == same function called with different params" if you're really not understanding what that post was trying to convey. (I realize you probably couldn't and won't be bothered to read what I was replying to, but just in case) I'm just making sure anybody reading those posts realizes what a nasty bug they can unleash by not using bases with parseInt. Not picking on you or anybody in particular.
|
# ¿ Sep 2, 2010 15:47 |
|
AshB posted:Edit: Okay I got this to work by completely removing all the Javascript. Apparently I only needed html for this. But just for my info, what's the proper way of using Javascript to get the value of the selected item in a drop-down menu? code:
|
# ¿ Oct 20, 2010 00:29 |
|
Douglas Crockford posted:Google wants their Java to run anywhere, so they translate it into javascript.
|
# ¿ Nov 16, 2010 06:42 |
|
NotShadowStar posted:That reminds me, is there some sort of command-line JSLint like YUICompressor? I use the Rhino-based YUI compressor as a part of a build system and it's really handy. It looks like there used to be but it doesn't exist anymore. For another option, I wrote about how to do this using the Windows Scripting Host a while ago, the post is about running it as an editor tool but most of it is still applicable. http://patcavit.com/2010/05/11/jslint-in-programmers-notepad-revisited/
|
# ¿ Jan 11, 2011 22:34 |
|
Boz0r posted:I'm trying to learn javacsript by studying code and I'd like to know what the following line does: It's a ternary conditional.
|
# ¿ Mar 26, 2011 19:08 |
|
smug forum rear end in a top hat posted:YUI Doc looks pretty good to me. I don't use it but it was suggested in a book about Javascript Patterns I sorta read a few months ago. YUI Doc is pretty good, definitely recommend you check out the Dana theme for it if you go that route.
|
# ¿ Mar 29, 2011 06:34 |
|
Adahn the nameless posted:I'm interested in learning javascript from some ASP.NET stuff I want to do. Does anyone have a recommended introduction site or something along those lines? http://eloquentjavascript.net/ Also seconding the recommendation for Crockford's book, just go into it knowing that he is VERY opinionated & you don't have to agree with everything he says.
|
# ¿ Apr 11, 2011 05:19 |
|
|
# ¿ Apr 29, 2024 01:00 |
|
Small White Dragon posted:Hey, the Google+ button has code like the following if you change the language: Chances are good they parse the DOM, looking for the <script> with the right src attribute, & then read its innerHTML. You don't get access to the content between <script> that have a src natively, but you can kludge it a bit. Since it's JSON you can then JSON.parse(script.innerHTML) to get a useful config object out of it.
|
# ¿ Jul 11, 2011 21:30 |