Hacker News new | ask | show | jobs
by gooderlooking 5121 days ago
Maybe I'm the only one who missed the memo, but in case anyone else is wondering what a hash is doing in JS:

"When writing (in text, not in JavaScript) about properties on specific prototypes, you may use the JavaScript notation, foo.prototype.bar. However, this shorter (non-JavaScript) notation is often used instead: foo#bar. Basically, the hash (#) stands for .prototype. — fancy huh?"

http://mathiasbynens.be/notes/javascript-prototype-notation

4 comments

This was confusing for me as well. Why on earth would anyone create a separate "text" notation for a programming language?

Please just stick to writing out ".prototype", if writing for a general audience.

You're not alone. I've never seen this before either.

Look, when you're writing an article about programming, stick to spelling things out properly.

It's ok to use acronyms when talking about companies (AT&T, IBM), nations (USA, USSR), or long technical terms as long as you define them early in the document so the reader knows what to expect.

Programming docs should explicitly refer to code in the language being discussed. Array.prototype.sort tells me exactly what you're talking about and my brain doesn't have to make mental leaps to understand what is being said. If its a language I'm not familiar with, like Objective C for example, then I probably will want to copy and search on code being demoed to learn about it. This would be very hard to do if I have to translate your custom abbreviations into the terminology everyone else in the world uses.

Keep it simple and succinct.

A bit confusing since it's a common convention to use # to refer to instance members, e.g. Foo#bar means my_instantiation_of_foo.bar
That's exactly what happens in the JavaScript case:

  new Array().sort === Array.prototype.sort # true
It's a Ruby-ism.
I've seen it in Javadoc doc comments as well.