<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
	
	>
<channel>
	<title>Comments on: You think you know javascript. Quiz results!</title>
	<atom:link href="/2012/03/07/you-think-you-know-javascript-quiz-results/feed/" rel="self" type="application/rss+xml" />
	<link>/2012/03/07/you-think-you-know-javascript-quiz-results/</link>
	<description>on web development</description>
	<lastBuildDate>Fri, 26 Oct 2018 21:40:18 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.3</generator>
	<item>
		<title>By: Marcos Minond</title>
		<link>/2012/03/07/you-think-you-know-javascript-quiz-results/comment-page-1/#comment-20430</link>
		<dc:creator><![CDATA[Marcos Minond]]></dc:creator>
		<pubDate>Tue, 21 Jan 2014 00:30:40 +0000</pubDate>
		<guid isPermaLink="false">/?p=2854#comment-20430</guid>
		<description><![CDATA[@BenJM - I think you&#039;re missing the point. What I think you&#039;re trying to say is that declaring variables in such a way is not secure because you can see the function and the source code.

But that variable *is* private. You&#039;re not changing or accessing a variable.  What you&#039;re doing is overwriting the whole function.]]></description>
		<content:encoded><![CDATA[<p>@BenJM &#8211; I think you&#8217;re missing the point. What I think you&#8217;re trying to say is that declaring variables in such a way is not secure because you can see the function and the source code.</p>
<p>But that variable *is* private. You&#8217;re not changing or accessing a variable.  What you&#8217;re doing is overwriting the whole function.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BenJM</title>
		<link>/2012/03/07/you-think-you-know-javascript-quiz-results/comment-page-1/#comment-18613</link>
		<dc:creator><![CDATA[BenJM]]></dc:creator>
		<pubDate>Thu, 11 Apr 2013 19:53:43 +0000</pubDate>
		<guid isPermaLink="false">/?p=2854#comment-18613</guid>
		<description><![CDATA[Nothing is private in JavaScript.
wrapping variables in functions is a nice way to prevent scripts from accidentally over writing variables but in no way makes them inaccessible.

&lt;a / rel=&quot;nofollow&quot;&gt;http://jsfiddle.net/Px4Nq/1/&lt;/a&gt;
It may not be a common example, but it illustrates the point.]]></description>
		<content:encoded><![CDATA[<p>Nothing is private in JavaScript.<br />
wrapping variables in functions is a nice way to prevent scripts from accidentally over writing variables but in no way makes them inaccessible.</p>
<p><a / rel="nofollow">http://jsfiddle.net/Px4Nq/1/</a><br />
It may not be a common example, but it illustrates the point.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DJW</title>
		<link>/2012/03/07/you-think-you-know-javascript-quiz-results/comment-page-1/#comment-15337</link>
		<dc:creator><![CDATA[DJW]]></dc:creator>
		<pubDate>Thu, 22 Mar 2012 04:43:21 +0000</pubDate>
		<guid isPermaLink="false">/?p=2854#comment-15337</guid>
		<description><![CDATA[@MM - What I meant was closures are messy when used as a solution to the lack of private methods. That is, the solution is a little more complex than it could be, compared to just being able to write &quot;private&quot; in the declaration.

I&#039;m certainly not saying closures are not elegant and powerful when used properly. But they can cause irksome memory leaks when you don&#039;t pay careful attention to what you are doing. I&#039;ve definitely caused problems for myself this way. But obviously it&#039;s my lack of knowledge, not the closures themselves, that&#039;s the problem. :-) I&#039;d still much rather have them than not.]]></description>
		<content:encoded><![CDATA[<p>@MM &#8211; What I meant was closures are messy when used as a solution to the lack of private methods. That is, the solution is a little more complex than it could be, compared to just being able to write &#8220;private&#8221; in the declaration.</p>
<p>I&#8217;m certainly not saying closures are not elegant and powerful when used properly. But they can cause irksome memory leaks when you don&#8217;t pay careful attention to what you are doing. I&#8217;ve definitely caused problems for myself this way. But obviously it&#8217;s my lack of knowledge, not the closures themselves, that&#8217;s the problem. 🙂 I&#8217;d still much rather have them than not.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marcos Minond</title>
		<link>/2012/03/07/you-think-you-know-javascript-quiz-results/comment-page-1/#comment-15334</link>
		<dc:creator><![CDATA[Marcos Minond]]></dc:creator>
		<pubDate>Thu, 22 Mar 2012 01:43:29 +0000</pubDate>
		<guid isPermaLink="false">/?p=2854#comment-15334</guid>
		<description><![CDATA[@Stoimen - Yes, I knew you were going to say that, but that&#039;s different though. What you are talking about is private &lt;i&gt;scope&lt;/i&gt;, not a private &lt;i&gt;method&lt;/i&gt;. Though they allow for similar results, those two things are very, very different.

@DJW - Messy closures? The moment Javascript became my favorite programming language was when I learned about closures (or function scope.) Javascript&#039;s closure/scope works as a function call stack, with each function call being saved in memory (this is what makes scope possible and other things like recursion, and currying.) Every function instance has access to its own declared variables and to it&#039;s parent&#039;s variables, and it&#039;s parent&#039;s parent, and so on.

@Stoimen - Good test though. I really like how you&#039;re displaying your results. The graphs look really good.]]></description>
		<content:encoded><![CDATA[<p>@Stoimen &#8211; Yes, I knew you were going to say that, but that&#8217;s different though. What you are talking about is private <i>scope</i>, not a private <i>method</i>. Though they allow for similar results, those two things are very, very different.</p>
<p>@DJW &#8211; Messy closures? The moment Javascript became my favorite programming language was when I learned about closures (or function scope.) Javascript&#8217;s closure/scope works as a function call stack, with each function call being saved in memory (this is what makes scope possible and other things like recursion, and currying.) Every function instance has access to its own declared variables and to it&#8217;s parent&#8217;s variables, and it&#8217;s parent&#8217;s parent, and so on.</p>
<p>@Stoimen &#8211; Good test though. I really like how you&#8217;re displaying your results. The graphs look really good.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stoimen</title>
		<link>/2012/03/07/you-think-you-know-javascript-quiz-results/comment-page-1/#comment-15329</link>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
		<pubDate>Wed, 21 Mar 2012 09:14:21 +0000</pubDate>
		<guid isPermaLink="false">/?p=2854#comment-15329</guid>
		<description><![CDATA[@DJW - Well, JavaScript is a functional, not a procedural programming language, so functions are objects and everything defined within their scope is visible only inside them. That makes these variables/functions/objects private. It&#039;s natural that js is so different from Java/PHP/ASP.

Thanks for the comment, I&#039;m glad you like the quiz series!]]></description>
		<content:encoded><![CDATA[<p>@DJW &#8211; Well, JavaScript is a functional, not a procedural programming language, so functions are objects and everything defined within their scope is visible only inside them. That makes these variables/functions/objects private. It&#8217;s natural that js is so different from Java/PHP/ASP.</p>
<p>Thanks for the comment, I&#8217;m glad you like the quiz series!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DJW</title>
		<link>/2012/03/07/you-think-you-know-javascript-quiz-results/comment-page-1/#comment-15328</link>
		<dc:creator><![CDATA[DJW]]></dc:creator>
		<pubDate>Wed, 21 Mar 2012 09:10:57 +0000</pubDate>
		<guid isPermaLink="false">/?p=2854#comment-15328</guid>
		<description><![CDATA[Oh, the closures solution. I dunno, I&#039;ve always thought of that as a workaround. JS closures are so much messier than a private function in, say, Java. 

I get what you mean, though. It is possible to mimic the functionality of private functions and variables using closures. In that sense you can have them in JS. But I hope you&#039;d agree that it&#039;s not the same thing - and not nearly as simple - as most OO languages. I would give just about anything to be able to have a &quot;private&quot; and &quot;protected&quot; keyword in JS that functioned the same way as in Java.

Quiz results are interesting, though. It&#039;s nice to see what the general consensus about these things is. Nice idea. The various different graphs are fun, too :-)]]></description>
		<content:encoded><![CDATA[<p>Oh, the closures solution. I dunno, I&#8217;ve always thought of that as a workaround. JS closures are so much messier than a private function in, say, Java. </p>
<p>I get what you mean, though. It is possible to mimic the functionality of private functions and variables using closures. In that sense you can have them in JS. But I hope you&#8217;d agree that it&#8217;s not the same thing &#8211; and not nearly as simple &#8211; as most OO languages. I would give just about anything to be able to have a &#8220;private&#8221; and &#8220;protected&#8221; keyword in JS that functioned the same way as in Java.</p>
<p>Quiz results are interesting, though. It&#8217;s nice to see what the general consensus about these things is. Nice idea. The various different graphs are fun, too 🙂</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stoimen</title>
		<link>/2012/03/07/you-think-you-know-javascript-quiz-results/comment-page-1/#comment-15325</link>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
		<pubDate>Wed, 21 Mar 2012 08:22:47 +0000</pubDate>
		<guid isPermaLink="false">/?p=2854#comment-15325</guid>
		<description><![CDATA[@Marcos, @DJW - yes you can have private methods in JavaScript. As you know in JS every function is an object. So the following code describes an object an all object defined inside this object are private. Global objects though are public. 

&lt;pre lang=&quot;javascript&quot;&gt;
// this object is global
var f = function() { return &#039;hello world!&#039; };

function g() 
{
        // f is public here, cause is global
	return &quot;g: &quot; + f();
}

// hello world
console.log(f());
// g: hello world
console.log(g());

function h()
{
        // f is private here, cause it&#039;s defined into h()
	var f = function() {
		return &#039;goodbye world&#039;;
	}

	return &quot;h: &quot; + f();
}

// hello world
console.log(f());
// h: goodbye world
console.log(h());
&lt;/pre&gt;

You can also take a look at one of my older articles: OOP JavaScript: &lt;a href=&quot;/2011/07/28/oop-javascript-accessing-public-methods-in-private-methods/&quot; title=&quot;OOP JavaScript&quot; rel=&quot;nofollow&quot;&gt;Accessing Public Methods in Private Methods&lt;/a&gt;]]></description>
		<content:encoded><![CDATA[<p>@Marcos, @DJW &#8211; yes you can have private methods in JavaScript. As you know in JS every function is an object. So the following code describes an object an all object defined inside this object are private. Global objects though are public. </p>
<pre lang="javascript">
// this object is global
var f = function() { return 'hello world!' };

function g() 
{
        // f is public here, cause is global
	return "g: " + f();
}

// hello world
console.log(f());
// g: hello world
console.log(g());

function h()
{
        // f is private here, cause it's defined into h()
	var f = function() {
		return 'goodbye world';
	}

	return "h: " + f();
}

// hello world
console.log(f());
// h: goodbye world
console.log(h());
</pre>
<p>You can also take a look at one of my older articles: OOP JavaScript: <a href="/2011/07/28/oop-javascript-accessing-public-methods-in-private-methods/" title="OOP JavaScript" rel="nofollow">Accessing Public Methods in Private Methods</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DJW</title>
		<link>/2012/03/07/you-think-you-know-javascript-quiz-results/comment-page-1/#comment-15322</link>
		<dc:creator><![CDATA[DJW]]></dc:creator>
		<pubDate>Tue, 20 Mar 2012 23:53:29 +0000</pubDate>
		<guid isPermaLink="false">/?p=2854#comment-15322</guid>
		<description><![CDATA[How is it possible to have private methods in a JS object? Anything defined in an object is accessible from outside the object. As far as I know there is no way to prevent this, which is why people tend to start &quot;private&quot; function names with an underscore. It&#039;s a visual reminder that is necessary precisely because there is no way to actually make them private. Or am I missing something?]]></description>
		<content:encoded><![CDATA[<p>How is it possible to have private methods in a JS object? Anything defined in an object is accessible from outside the object. As far as I know there is no way to prevent this, which is why people tend to start &#8220;private&#8221; function names with an underscore. It&#8217;s a visual reminder that is necessary precisely because there is no way to actually make them private. Or am I missing something?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marcos Minond</title>
		<link>/2012/03/07/you-think-you-know-javascript-quiz-results/comment-page-1/#comment-15309</link>
		<dc:creator><![CDATA[Marcos Minond]]></dc:creator>
		<pubDate>Sun, 18 Mar 2012 03:25:57 +0000</pubDate>
		<guid isPermaLink="false">/?p=2854#comment-15309</guid>
		<description><![CDATA[You cannot make an object&#039;s method private, please explain your answer to question 4.]]></description>
		<content:encoded><![CDATA[<p>You cannot make an object&#8217;s method private, please explain your answer to question 4.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
