Whats "@" used for?

130 views
Skip to first unread message

Kevin Ingwersen

unread,
May 19, 2014, 4:09:25 AM5/19/14
to nod...@googlegroups.com
Hey.

Short question; what is the @ operator used for in JS?
in PHP, its the „silence errors“ operator.

Kind regards, Ingwie.


--
"Yo Dawg, I heard you like C++, so I  added C++ to your build system, so you have to compile before you compile.“ -StackOverflow, Matt Joiner ( http://stackoverflow.com/a/5025525/2423150 )

William Dias

unread,
May 19, 2014, 8:52:40 AM5/19/14
to nod...@googlegroups.com, ingwi...@googlemail.com
Hi,

The @ is an illegal token in JS.
You may be confused with the "@" operator of coffeescript (that compiles to javascript and is widely used) that is just an alias for "this".

Bence Dányi

unread,
May 19, 2014, 4:43:56 AM5/19/14
to nod...@googlegroups.com
Hi Ingwie,

there is no @ operator in javascript (at the moment).

Bence
:wq
> --
> Job board: http://jobs.nodejs.org/
> New group rules:
> https://gist.github.com/othiym23/9886289#file-moderation-policy-md
> Old group rules:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nodejs+un...@googlegroups.com.
> To post to this group, send email to nod...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nodejs/CA2C2220-BD0E-49FB-B027-746D3D74CA87%40googlemail.com.
> For more options, visit https://groups.google.com/d/optout.

Angel Java Lopez

unread,
May 19, 2014, 6:14:17 AM5/19/14
to nod...@googlegroups.com
Sorry, I don't know a code that uses @ in Node.js

Do you have code to show?

Node.js is based on JavaScript, I didn't find the @ operator at (not pun intended ;-)


Angel "Java" Lopez
@ajlopez



Alan Hoffmeister

unread,
May 19, 2014, 6:19:20 AM5/19/14
to nodejs
In JavaScript we use it in e-mail strings.
--
Att,
Alan Hoffmeister

Ryan Schmidt

unread,
May 19, 2014, 7:52:02 AM5/19/14
to nod...@googlegroups.com

On May 19, 2014, at 03:09, Kevin Ingwersen wrote:

> Short question; what is the @ operator used for in JS?
> in PHP, its the „silence errors“ operator.

Maybe I'm not awake yet, but I cannot recall "@" being used as an operator in JavaScript. Have you seen code where this is used? If so, please share it with us.

Rick Waldron

unread,
May 19, 2014, 11:46:00 AM5/19/14
to nod...@googlegroups.com
Nothing as of yet, but there are proposals for ES7 to use it as a private property prefix: 


function Foo() {
  this.@privy = true;
  this._privy = false
}

var foo = new Foo();

foo; 

{ _privy: false } <-- no access to @privy property


Rick




Mariano Pardo

unread,
May 19, 2014, 4:16:08 PM5/19/14
to nod...@googlegroups.com
In ES6 proposal, you can use @ for annotations.
A great example is the DI from angular 2 (https://www.npmjs.org/package/ng-annotate).

Mariano


Kevin Ingwersen

unread,
May 19, 2014, 1:14:57 PM5/19/14
to nod...@googlegroups.com
Thanks for the replies!

I was only asking, as I accidentially typed @ into nodejs’ REPL and it showed me the „…“ thing…so I got confused.

I would vote for the proposal in ES7. It looks very nice to me.



--
"Yo Dawg, I heard you like C++, so I  added C++ to your build system, so you have to compile before you compile.“ -StackOverflow, Matt Joiner ( http://stackoverflow.com/a/5025525/2423150 )

David Jacobs

unread,
May 19, 2014, 5:28:23 PM5/19/14
to nod...@googlegroups.com
Annotations are out of control in the Java world. It's a slippery slope; it looks nice in the simplest case, but as the use cases evolve, the annotations expand, including many additional properties for each annotation, more sophisticated meta directives, and even small scripts. Then it is code, just as much as the "actual" code, except sitting within an alternate and awkward demarcation syntax, for no good reason. In retrospect, you're left wondering "how did it come to this?! This is stupid."

Why wait for the retrospective regret? It's stupid right now.

-David
@MetaThis


Rick Waldron

unread,
May 19, 2014, 5:35:17 PM5/19/14
to nod...@googlegroups.com
On Mon, May 19, 2014 at 4:16 PM, Mariano Pardo <maria...@gmail.com> wrote:
In ES6 proposal, you can use @ for annotations.

Presumably you're referring to this: https://github.com/google/traceur-compiler/wiki/LanguageFeatures#annotations-experimental Note that this "feature" has no official strawman. 

A great example is the DI from angular 2 (https://www.npmjs.org/package/ng-annotate).

These are just comment-based annotations.

Rick
 
Reply all
Reply to author
Forward
0 new messages