- This topic is empty.
-
AuthorPosts
-
June 20, 2014 at 1:33 pm #173328chrisburtonParticipant
Anyone have any idea what code this entails? http://www.stanford.edu/class/cs101/code-1-exercises.html
I thought it was Javascript but after testing, something entirely different happens (e.g.
print()
brings up the printer settings).June 20, 2014 at 1:42 pm #173329nixnerdParticipantLooks like Python… save for the semicolons.
June 20, 2014 at 2:14 pm #173335Paulie_DMemberI hit the backlink at the top of the page and it seems to be a javascript course.
EDIT –
Aha
Note “print” is not a normal part of Javascript, I added it for CS101
June 20, 2014 at 2:32 pm #173337chrisburtonParticipant@Paulie_D Where do you see that quote?
I find it completely stupid to teach
print();
as if it actually does what it shows when it actuality, it doesn’t. It’s just confusing. After briefly reading through some docs it states thatprint();
is a function so that is why it’s acting comparable todocument.write();
.June 20, 2014 at 2:52 pm #173339Paulie_DMemberI hit the backlink and then selected the introduction link.
When he first demos ‘print’ in the first code example, it’s the last comment in the green boxed”notes”.
June 20, 2014 at 3:03 pm #173340chrisburtonParticipantGotcha. Thanks.
June 20, 2014 at 5:51 pm #173348__ParticipantI find it completely stupid to teach
print()
as if it actually does what it shows when it actuality, it doesn’t.Well, it does do what it shows. It’s just not a native JS function: it’s a user-defined function.
Here’s it’s definition, if you’re interested:
// Print any number of things, separated by spaces and ending with a carriage return. function print() { // printlimit feature if (window.globalPrintCount <= 0) { if (window.globalPrintCount == 0) { printOne("***print output limited***"); printOne("<br>"); window.globalPrintCount--; } return; } window.globalPrintCount--; for (var i=0; i<arguments.length; i++) { printOne(arguments[i]); } printOne("<br>"); }
[JavaScript] syntax is strict and narrow
LOL
June 20, 2014 at 8:15 pm #173353chrisburtonParticipantWell, it does do what it shows. It’s just not a native JS function: it’s a user-defined function. @traq
What I mean is that
print()
seems to already be native to JS (from my testing it opens printer settings) so creating a user-defined function to change that seems kind of stupid to teach because it can be confusing.June 20, 2014 at 8:35 pm #173354__ParticipantWhat I mean is that print() seems to already be native to JS (from my testing it opens printer settings)…
Ha! Was not aware of that. Upon research, it seems it’s not part of any spec, but is supported basically everywhere. Given this, yes, I agree that creating a UDF named
print
is “kind of stupid.” -
AuthorPosts
- The forum ‘Other’ is closed to new topics and replies.