TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

A re-introduction to JavaScript

290 pointsby hikzabout 10 years ago

16 comments

jongduboisabout 10 years ago
I think there&#x27;s no point trying to avoid memory leaks in older versions of IE. Circular references due to closures are too common and it&#x27;s not worth messing with your code.<p>IE users are probably used to getting a horrible user experience anyway. I&#x27;m sure they can cope with a few browser freezes&#x2F;crashes every once in a while - They know how to take a beating :p
评论 #9516920 未加载
评论 #9516726 未加载
评论 #9517178 未加载
评论 #9517199 未加载
PhineasRexabout 10 years ago
&quot;While often derided as a toy&quot;<p>Javascript is not a toy; toys are fun.
评论 #9518106 未加载
评论 #9516590 未加载
kremlinabout 10 years ago
The article mentions an idiom for iterating over an array. It says &#x27;an even nicer idiom is...&#x27; and then it shows it.<p>I just wanted to say that the behaviour of this &#x27;nicer&#x27; idiom may not be what&#x27;s expected - it stops iterating once it hits the first falsy value. I was quite excited actually when I first saw them idiom, until I quickly realized its limitations
评论 #9516601 未加载
评论 #9516599 未加载
评论 #9516860 未加载
评论 #9529673 未加载
efbbbfabout 10 years ago
<a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=7169513" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=7169513</a><p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=3569893" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=3569893</a><p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=1524450" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=1524450</a><p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=601967" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=601967</a>
评论 #9516435 未加载
serve_yayabout 10 years ago
Very nice to see it starts off with a (correct) discussion of JS types! JS devs mostly don&#x27;t know the actual types in JS, which is pretty crazy if you think about it.
评论 #9516344 未加载
gildasabout 10 years ago
&gt; You can also use the unary + operator to convert values to numbers:<p><pre><code> + &quot;42&quot;; &#x2F;&#x2F; 42 </code></pre> &gt; [...] However the &quot;+&quot; operator simply converts the string to NaN if there is any invalid character in it.<p>Being a bit pedantic here, why not recommending the Number function which may be less obscure for beginners?<p><pre><code> Number(&quot;42&quot;); &#x2F;&#x2F; 42</code></pre>
评论 #9518583 未加载
评论 #9518039 未加载
评论 #9516580 未加载
评论 #9516746 未加载
评论 #9517168 未加载
评论 #9516594 未加载
评论 #9516584 未加载
评论 #9517967 未加载
ffnabout 10 years ago
Whoa, the closure-based circular reference memory leak thing, is that just an IE issue or is that a language level (anti) feature? I need to know because I&#x27;ve very often done something like:<p>el$ = $(&#x27;#whatever&#x27;); el$.click( function() { el$.find(&quot;a&quot;).css(&quot;color&quot;, &quot;red&quot;); } );
z3t4about 10 years ago
I think it&#x27;s much easier to forget about &quot;types&quot; and think of objects instead. Trying to divide JavaScript objects into &quot;types&quot; will surely get you frustrated. If you absolutely want to check what &quot;type&quot; an object is, for example a sanity check for arguments passed to a function, you should make your own isMyType(obj) function and not rely on typeof or toString.
评论 #9518629 未加载
评论 #9517480 未加载
snorrahabout 10 years ago
The article says to watch out for 0.1 + 0.2 not exactly equalling 0.3 , so as a complete newbie to JavaScript, how do you work around this ?
评论 #9516783 未加载
评论 #9516934 未加载
评论 #9516635 未加载
评论 #9517235 未加载
philboabout 10 years ago
&quot;JavaScript is an object oriented...&quot;<p>No it isn&#x27;t. It has support for OO and you can choose to write code object-oriented if you wish. But equally you can disregard the OO bit quite happily and compose behaviour using closures instead.<p>None of my favourite JS libs are OO, it&#x27;s a poor abstraction imho.
dorfsmayabout 10 years ago
This is a really good overview.<p>Along the same line but more in depth, I really like Cody Lindley&#x27;s JavaScript Enlightenment:<p><a href="http:&#x2F;&#x2F;www.javascriptenlightenment.com&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.javascriptenlightenment.com&#x2F;</a>
Nicanabout 10 years ago
For the second example on the memory leak section (<a href="https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;JavaScript&#x2F;A_re-introduction_to_JavaScript#Memory_leaks" rel="nofollow">https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;JavaScript&#x2F;A_re...</a>), wouldn&#x27;t just changing &quot;el.style&quot; to &quot;this.style&quot; fix the memory leak?
totonyabout 10 years ago
I wish there were more tutorials of this style, for people who are already familiar with programming and just want to know how a language works.
ww520about 10 years ago
One caveat not mentioned is that while float is 64 bit floating point number, int is only 53 bit integer, unlike having 64 bit int in most other languages. Yeah, I&#x27;ve got bitten by this before causing a nasty bug.
评论 #9518472 未加载
评论 #9518325 未加载
anon3_about 10 years ago
Cool. Did Brendan Eich write it? What&#x27;s he doing these days?<p>Keep up the good work Mozilla.<p>edit: I see MANY people contributed! You can too! <a href="https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Mozilla&#x2F;Connect" rel="nofollow">https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Mozilla&#x2F;Connect</a>. It still would be cool if Eich could act as an &quot;editor&quot; to JS related articles!
kelvin0about 10 years ago
Rediscover Javascript, by using :TypeScript, CoffeeScript or Node.js and a gazillion of slightly incompatible web frameworks ... I wish DART had been there in the beginning.