Talk:Basic JavaScript

From Wikiversity
Jump to: navigation, search

Working Together[edit]

Hamshire2004 would you like to create more guides together with me? I think it would benefit us and the user reading our guides.

--Xora 19:01, 21 May 2007 (UTC)

Goals[edit]

In order to get a general idea of where the Basic JavaScript article is going, perhaps goals should be set for the Basic JavaScript course. Likely these should include

  • Variables/Operators and Functions (discussing how to declare a basic variable and a basic function)
  • Language Constructs (i.e., if statements, case statements, loops, etc.)
  • Possibly forms, HTML input features, etc.

Any suggestions? What exactly should distinguish the Basic JavaScript course from the intermediate one?

Hampshire2004 17:34, 16 May 2007 (UTC)


I've started the second lesson, but it needs more information on operators and arrays (and possibly some more explanation on variables). Another possibility would be to add some suggested exercises.

Hampshire2004 20:05, 17 May 2007 (UTC)

Local example[edit]

We have MediaWiki:Common.js and MediaWiki:Monobook.js in place and have fiddled with them some. This might be a good place to learn how MediaWiki and Javascript can work together. We just have to make sure things are fully explained and there is consensus from the community when editing the actual scripts. Also, it is important to learn how the JavaScripts interact with MediaWiki:Common.css and MediaWiki:Monobook.css. Just a thought. See the MediaWiki Project page for some ideas -- CQ 20:17, 21 May 2007 (UTC)

That's cool! I didn't realize that there was a MediaWiki project within Wikiversity. Though probably not in the basic course(!), a research project could definitely be started within the JavaScript section on using JavaScript with wiki software. When you refer to getting consensus, though, do you mean that you think we might end up actually modifying part of the scripts as part of a project? Is there a safe way to experiment with the software? Hampshire2004 11:59, 23 May 2007 (UTC)
The Common.js and Monobook.js pages in the MediaWiki: namespace show up site-wide, hense consensus should be reached befor changing them. However, you can add monobook.js and monobook.css pages to your User: space - Example: User:Sebmol/monobook.js, User:Sebmol/monobook.css. I'm not yet aquainted with how to implement this, but obviously there are people here and many at Wikipedia who are. Maybe we can work this into a research and development project. BTW, Hampshire2004, where's your user page? CQ 16:49, 23 May 2007 (UTC)

Comments[edit]

In this sentence: "For the purposes of this course, though, you should only ever need to use the JavaScript tag." The type="text/javascript" is an attribute of the style tag, and text/javscript is a mine type. What is a JavaScript tag exactly?

And in this sentence: "Well, document.write() is the JavaScript standard for writing text to the browser window." Who says? Can we get a source for that please? Personally, I'd recommend the innerHTML method. Yes, w3 has depricated it. But ask yourself why ALL browser venders continue to support it? It's because of it's popularity, and it's highly unlikely, in fact, I'd put money down saying that innerHTML will not become unsupported anytime in the near future.

Additionally, if your script is in the header, document.write inserts at the beginning of the body tag. What happens if you want to insert after some child, or grandchild node in the body? document.write would require that your script be placed in the exact spot you want your text.

All of that combined, I think, makes document.write NOT the defacto standard for writing text to the document. In fact, it's usefulness, in my opinion, is almost entirely limited to debugging.

If you are creating an entire document with javascript, and ALL of the content in the body is generated by javascript, then I could see using document.write in a production environment. And that seems a rather limited production use, no?

And another thing, it's sloppy technique to not terminate lines of code with a semicolon. I'll use Douglas Crockford, creator of JSLint, and Javascript Architect at YAHOO for a source on that. http://developer.yahoo.com/yui/theater/ That link contains videos of D. Crockford's talks on Javascript were you can see him saying just that.

I can barely bring myself to read any further...

But here's one last tidbit: "One of the things JavaScript is used for is the manipulation of data. In JavaScript, pieces of data can be stored either in variables or arrays."

Um, being a totally object oriented language, how could you possibly leave out objects as a way to store data? /me shakes head...

Oh okay, one more. lol "This may allow him..." Obviously, not all programmers are men. Perhaps a more gender neutral style is called for in the 21st century? Edited by Floydian at www.phphorizons.com

Mistake[edit]

Should it not read:

document.write("The color of a cherry is " + colors["cherry"] + ", but the color of a lime is " + colors["lime"]);

instead of:

document.write("The color of a cherry is " + colors[cherry] + ", but the color of a lime is " + colors[lime]);

for the given example?--JimmyK 22:51, 22 July 2009 (UTC)