<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>  Art &#38; Technology   @ NHTV &#187; javascript</title>
	<atom:link href="http://gamer-powered.com/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://gamer-powered.com</link>
	<description>student blog</description>
	<lastBuildDate>Fri, 02 Jul 2010 15:17:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Week 4: javascript</title>
		<link>http://gamer-powered.com/2009/10/week-4-javascript/</link>
		<comments>http://gamer-powered.com/2009/10/week-4-javascript/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 11:11:25 +0000</pubDate>
		<dc:creator>Leroy</dc:creator>
				<category><![CDATA[Introduction into Client Technologies: HTML]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://gamer-powered.com/?p=58</guid>
		<description><![CDATA[For week 4, I was pretty confident I&#8217;d be able to do the javascript assignment quickly. Having never really used JS, but being relatively experienced with C++, I felt at home with it instantly due to the the identical syntax, so the only thing I had to learn were some minor differences between the languages [...]]]></description>
			<content:encoded><![CDATA[<p>For week 4, I was pretty confident I&#8217;d be able to do the javascript assignment quickly. Having never really used JS, but being relatively experienced with C++, I felt at home with it instantly due to the the identical syntax, so the only thing I had to learn were some minor differences between the languages and the document object model, which turned out to be quite some work still, but only took me a short while to figure out with the internet to reference. All in all, I think it took me about an hour and a half to have the bug-free assignment done and I&#8217;m very pleased with that. the DOM is still a bit scary, but was easier to play with than I though it would be.</p>
<p>You can basically set the name and id tags of a div or a other tag, and address html elements, or groups of elements using those using getElementById or getElementByName which return objects for you to work with. the only real difference between JS and C/++ was with function declarations/implementations where you don&#8217;t need to specify a return type, nor do you need to specify the variable types, or even use the var statement for function arguments.</p>
<p>I&#8217;ll give an example:<br />
First one is a function in JS</p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="vertical-align: top;">
<pre style="font-family: 'Bitstream Vera Sans Mono', Monaco, 'Courier New', monospace; font-size: 9pt; margin-top: 0em; line-height: 1.3em; color: #999999; padding-right: 2em; text-align: right;">1
2
3
4
5
6
7
8</pre>
</td>
<td style="vertical-align: top;">
<pre style="font-family: 'Bitstream Vera Sans Mono', Monaco, 'Courier New', monospace; font-size: 9pt; line-height: 1.3em; margin-top: 0em; word-wrap: break-word; color: #f8f8f8; background-color: #141414; padding: 0px;">
<pre style="font-family: 'Bitstream Vera Sans Mono', Monaco, 'Courier New', monospace; font-size: 9pt; line-height: 1.3em; margin-top: 0em;"><span style="padding-top: 0.2em; padding-bottom: 0.1em;"><span style="padding-top: 0.2em; padding-bottom: 0.1em; color: #f9ee98;">function</span> <span style="padding-top: 0.2em; padding-bottom: 0.1em; color: #9b703f;">PopulateOptions</span>(<span style="padding-top: 0.2em; padding-bottom: 0.1em; color: #7587a6;">options, max</span>)</span>
<span style="padding-top: 0.2em; padding-bottom: 0.1em;">{</span>
	<span style="padding-top: 0.2em; padding-bottom: 0.1em; color: #f9ee98;">var</span> i;
	<span style="padding-top: 0.2em; padding-bottom: 0.1em; color: #cda869;">for</span><span style="padding-top: 0.2em; padding-bottom: 0.1em;">(</span>i <span style="padding-top: 0.2em; padding-bottom: 0.1em; color: #cda869;">=</span> <span style="padding-top: 0.2em; padding-bottom: 0.1em; color: #cf6a4c;">0</span>; i <span style="padding-top: 0.2em; padding-bottom: 0.1em; color: #cda869;">&lt;</span> max; i<span style="padding-top: 0.2em; padding-bottom: 0.1em; color: #cda869;">++</span><span style="padding-top: 0.2em; padding-bottom: 0.1em;">)</span>
	<span style="padding-top: 0.2em; padding-bottom: 0.1em;">{</span>
		AddOption<span style="padding-top: 0.2em; padding-bottom: 0.1em;">(</span>options<span style="padding-top: 0.2em; padding-bottom: 0.1em;">, </span>i<span style="padding-top: 0.2em; padding-bottom: 0.1em;">)</span>;
	<span style="padding-top: 0.2em; padding-bottom: 0.1em;">}</span>
<span style="padding-top: 0.2em; padding-bottom: 0.1em;">}</span></pre>
</pre>
</td>
</tr>
</tbody>
</table>
<p>and the same function rewritten in C/++</p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="vertical-align: top;">
<pre style="font-family: 'Bitstream Vera Sans Mono', Monaco, 'Courier New', monospace; font-size: 9pt; margin-top: 0em; line-height: 1.3em; color: #999999; padding-right: 2em; text-align: right;">1
2
3
4
5
6
7
8</pre>
</td>
<td style="vertical-align: top;">
<pre style="font-family: 'Bitstream Vera Sans Mono', Monaco, 'Courier New', monospace; font-size: 9pt; line-height: 1.3em; margin-top: 0em; word-wrap: break-word; color: #f8f8f8; background-color: #141414; padding: 0px;">
<pre style="font-family: 'Bitstream Vera Sans Mono', Monaco, 'Courier New', monospace; font-size: 9pt; line-height: 1.3em; margin-top: 0em;"><span style="padding-top: 0.2em; padding-bottom: 0.1em; color: #f9ee98;">void</span> PopulateOptions(OptionsList* options, <span style="padding-top: 0.2em; padding-bottom: 0.1em; color: #f9ee98;">int</span> max)
{
	<span style="padding-top: 0.2em; padding-bottom: 0.1em; color: #f9ee98;">int</span> i;
	<span style="padding-top: 0.2em; padding-bottom: 0.1em; color: #cda869;">for</span>(i = <span style="padding-top: 0.2em; padding-bottom: 0.1em; color: #cf6a4c;">0</span>; i &lt; max; i++)
	{
		AddOption(options, i);
	}
}</pre>
</pre>
</td>
</tr>
</tbody>
</table>
<p>As you can see, nothing dramatic, pretty easy to understand and read!</p>
<p>Once again, pretty easy homework to do ; ]</p>
]]></content:encoded>
			<wfw:commentRss>http://gamer-powered.com/2009/10/week-4-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
