Killersites Forums

rbuser

Member

9

0

1. Newb question on the array.sort function

Well, thanks again, Ben. What I'm happiest about is that I wasn't missing something totally obvious, and that there must be something more complicated, as you say, occuring in the process. As you can imagine, I was the kid who incessantly asked "but why?" to everything I was told by parents, teachers, lol. It just bothers me when there's (sometimes) no full explanation of the process, but we're just expected to live with "hey, it works -- that's all you need to know!" These kinds of things are stumbling blocks for me, unfortunately, when I'm undertaking something new in life such as learning coding. I appreciate the assist.
2. Newb question on the array.sort function

Hi Ben, Thanks for doing that. It was both helpful yet still a little mysterious when I see the sequence play out. Here's how the code runs: Initial Array: myarray[0] is =>25 myarray[1] is =>8 myarray[2] is =>7 myarray[3] is =>41 Step 1 - a: 25 b: 8 - result: 17 Step 2 - a: 25 b: 7 - result: 18 Step 3 - a: 8 b: 7 - result: 1 Step 4 - a: 25 b: 41 - result: -16 Final Array: myarray[0] is =>7 myarray[1] is =>8 myarray[2] is =>25 myarray[3] is =>41 Notice "Step 3", where all of the sudden the value of a: changes to 8 vs its value of 25 in all the other steps. I'm still curious how/why that occurs. Sorry if I'm belaboring this, and I do appreciate the work you put into writing out the code!
3. Newb question on the array.sort function

Hi Ben, That's actually where I got the code, lol. I guess I'm asking this (and don't ask me why -- it's just something that will help me visualize it): In the sort example I used, say someone asked you, Ben, to write out step by step exactly what was happening as the function did it's math and comparison thing; the steps you don't SEE happening . What would you write? I'm thinking of something along the lines of: 1. a = 28 b=8 28 minus 8 means value a is larger than 0, and hence to the right of value b in the ascending sort order. 2. a = ?? b=?? a minus b = ?? 3. a = ?? b=?? a minus b = ?? etc. I guess I'm asking if anyone knows the exact process of what values are being compared to what other values. Since there are only two values that can be compared at any given instant, what values are they and in what order at any moment in time in the function processing? Does it depend on where they appear in the array? Make sense?
4. Newb question on the array.sort function

I'm trying to grasp what's going on "under the hood" of the array.sort function in Javascript. Let's use the following example: var myarray=[25, 8, 7, 41] myarray.sort(function(a,{return a - b}) //Array now becomes [7, 8, 25, 41] I know it might sound silly, but since the function takes two values -- a and b -- exactly which two values are being compared at any given time in the logic?? I understand the sorting "rules" in terms of <0, 0, and >0 re: sort order. I'm just wondering what, exactly is going on in the sort process in Javascript at each step of the function? In other words, is the first step to set parameter a to 25 and b to 8 and do the subtraction, then 25 - 7, then 25 - 41? This is what is seemingly never explained in the examples I see. Is it a loop that's being performed with every possible iteration of elements in the array subtracting from each other in this case? I'm wondering what is assigned to "a" and what to "b" at any given time while the function processes. (I don't know why "B" shows up in the code capitalized - I tried to make it lower-case but it wouldn't take.)
5. JS equivalent of "Echo"??

Yes, the newbiest of questions, 'tis true, but what is the JS equivalent of PHP's "Echo" command? I know about using the Alert box, but that's not what I want. I just want a simple "Hello World" on the page, not as a pop up. Now, I also know about document.write, too..BUT w3schools' page on this specifically says not to use it in "live" code because it could/would rewrite an entire page after loading. Here's their blurb: "Note: Try to avoid using document.write() in real life JavaScript code. The entire HTML page will be overwritten if document.write() is used inside a function, or after the page is loaded. However, document.write() is an easy way to demonstrate JavaScript output in a tutorial." There has to be something simple that just echoes to the screen in javascript without causing other problems, no? Note: This isn't one of those questions where I'm looking for people to ask "why do you even want JS to do that as there are better options?". It's just one of those "what's the equivalent" questions for my own knowledge. Thanks.
6. IE Hacks

Instead of talking about IE "Hacks", wouldn't it be more helpful to discuss "IE Conditional Comments"? I would think that IE Conditional Comments should not be considered "hacks" whatsoever, but merely ways to insert IE browser-specific code under certain defined scenarios that might correct IE display inconsistencies. Here's someone's page about it --not meant to be the be all and end all of explanations: IE Conditional Comments
7. CSS Layout videos use XHTML DocType? Not what Stef recommended...

I've been through a series of videos now here on HTML/CSS and am now starting to watch the CSS Layouts series (nicely done, btw). My question has to do with DocType selection. Stef made a big deal about NOT using the XHTML doctype in his earlier videos, and gave his compelling reasons why not to. And even though they were earlier videos, it's not like they were 10 years ago. He stated words to the effect that going forward, HTML Strict should remain the DocType one should use. But now I see in the CSS Layouts videos that the DocType being used is XHTML Transitional in the DreamWeaver presentation. As a beginner, I don't have a dog in the fight. But I would have thought that this is something philosophy-wise that Stef would have insisted on by other tutorial authors on his website. At the least, it's confusing to me as a beginner. Now, I know there will no doubt be people here who think that HTML Strict or XHTML Transitional is best, but I want the advice or at least usage to be consistent across the University website. Thoughts?
8. What order to watch ALL PHP videos

Thanks for the feedback.
9. What order to watch ALL PHP videos

Hi, One thing I've noticed about the KS University video library is that while there is a numbering system to videos in a particular section (Beginner's PHP, etc.), there doesn't seem to be a suggested order for one to follow when finished with the Beginner's section. In other words, after I am done with Beginner's PHP, should I go to "Advanced PHP", or rather as the library page shows, "Misc PHP", followed by "PHP CRUD", etc.? This is something that's bothered me about the KS University page presentation in general. Yes, I do understand that there is value in doing things a la carte if one wishes. But as a beginner, I'd rather have someone (i.e Stefan) point me to a very defined learning progression order so that things make the most sense to me as a student. I guess at its most fundamental, the question would be, "why are the library video sections shown in the order they are unless that's the order people should view them"? Thanks.
×