Live data from Hacker News

A re-introduction to JavaScript

developer.mozilla.org

1–10 of 115 posts

Re: A re-introduction to JavaScript

#2
I think there's no point trying to avoid memory leaks in older versions of IE. Circular references due to closures are too common and it's not worth messing with your code.

IE users are probably used to getting a horrible user experience anyway. I'm sure they can cope with a few browser freezes/crashes every once in a while - They know how to take a beating :p

Re: A re-introduction to JavaScript

#5

Very nice to see it starts off with a (correct) discussion of JS types! JS devs mostly don't know the actual types in JS, which is pretty crazy if you think about it.

I think 99% of the problems people have with Javascript are not actually types, but `this`.

It's the most confusing part about Javascript. This context, var foo scope, what? Why is this value not updating? undefined? What???

Re: A re-introduction to JavaScript

#7
post #3

https://news.ycombinator.com/item?id=7169513 https://news.ycombinator.com/item?id=3569893 https://news.ycombinator.com/item?id=1524450 https://news.ycombinator.com/item?id=601967

These are all roughly a year apart and it's a very interesting article. I don't really see a big problem with reposts that far apart to catch newcomers' eye.

Re: A re-introduction to JavaScript

#8
post #7
post #3

https://news.ycombinator.com/item?id=7169513 https://news.ycombinator.com/item?id=3569893 https://news.ycombinator.com/item?id=1524450 https://news.ycombinator.com/item?id=601967

These are all roughly a year apart and it's a very interesting article. I don't really see a big problem with reposts that far apart to catch newcomers' eye.

Apart from they wouldn't really be "news", which is supposedly what this site is for (as denoted by the site's name and URL).

Re: A re-introduction to JavaScript

#9

Very nice to see it starts off with a (correct) discussion of JS types! JS devs mostly don't know the actual types in JS, which is pretty crazy if you think about it.

I think 99% of the problems people have with Javascript are not actually types, but `this`. It's the most confusing part about Javascript. This context, var foo scope, what? Why is this value not updating? undefined? What???

I actually found the Javascript 'this' keyword more understandable after working with Python.

  >>> class foo():
  ...   def test(this, x):
  ...     print this, x
  ... 
  >>> x = foo()
  >>> x
  
  >>> x.test(1)
   1
  >>> y = foo.test
  >>> y(1)
  Traceback (most recent call last):
    File "", line 1, in 
  TypeError: unbound method test() must be called with foo instance as first argument (got int instance instead)
  >>> y(x,1)
   1
In Python, the reference to the current object is an explicitly declared parameter in the method definition, but the parameter is passed implicitly - the value of "this" is whatever is comes before the period when the method is called. If you call it in any other manner, it throws an unbound method error. Javascript is the same way, but instead of throwing an error it will instead pass 'window' implicitly. The equivalent code in Javascript:

  function foo() { }
  foo.prototype.test = function(x) {
    console.log(this, x);
  }
  var x = new foo();
  x.test(1); // prints VM1061:4 foo {test: function} 1
  var y = x.test;
  y(1); // prints VM1061:4 Window {top: Window, window: Window, …} 1

Re: A re-introduction to JavaScript

#10
post #8
post #7

Earlier quoted context omitted.

These are all roughly a year apart and it's a very interesting article. I don't really see a big problem with reposts that far apart to catch newcomers' eye.

Apart from they wouldn't really be "news", which is supposedly what this site is for (as denoted by the site's name and URL).

https://news.ycombinator.com/newsguidelines.html
Post reply on HN