I'm trying to allow '@' functions in my application, what should I add or insert to allow JS to interpret it, just like "angular2 @Component".
How to allow '@' keyword in Javascript
262 Views Asked by Jasdev Sidhu At
2
There are 2 best solutions below
0
Michael Troger
On
According to a variable name validator for JavaScript, @ is a:
invalid identifier according to ECMAScript 6 / Unicode 8.0.0
And so it is invalid for function names as well. See also: What characters are valid for JavaScript variable names? In Angular you actually use TypeScript and they make use of @ as a decorator of a function, but it's not used in a function name.
Related Questions in JAVASCRIPT
- Angular Show All When No Filter Is Supplied
- Why does a function show up as not defined
- I count the time the user takes to solve my quiz using Javascript but I want the same time displayed on another page
- Set "More" "Less" font size
- Using pagination on a table in AngularJS
- How to sort these using Javascript or Jquery Most effectively
- how to fill out the table with next values in array with one button
- State with different subviews
- Ajax jQuery firing multiple time display event for the same result
- Getting and passing MVC Model data to AngularJS controller
- Disable variable in eval
- javascript nested loops waiting for user input
- .hover() seems to overwrite .click()
- How to sort a multi-dimensional array by the second array in descending order?
- How do I find the fonts that are not loading in a CORS situation ( MoovWeb )?
Related Questions in TYPESCRIPT
- Use translateProvider.useLoader with Typescript
- Optional method in base class
- Putting Lambdas in OR statement
- Deleting namespace in Socket IO
- Angularjs+Typescript directive implementing $compile
- Typescript type inference inside for loop
- Why void functions are allowed in left part of assignment in Typescript?
- Tools for Apache Cordova - TypeScript debugger jumps to wrong line
- Typescript - is there a way to specify a global reference?
- How to angularjs app.service and $q in typescript
- include typescript file in output result build with TFS
- Mocking Angular $window in unit test cases
- Difference between `share()` and `publish().refCount()`
- TypeScript: workaround for relative reference path?
- How to define knex migrations using Typescript
Related Questions in ECMASCRIPT-6
- React, ES6 - getInitialState was defined on a plain JavaScript class
- jspm does not transpile code from ES6 to ES5
- XHR progress event microtask queue
- Compiling ES6 arrow functions to Es5 using Babel.js
- How to properly bind current object context in ES6 using babelify
- Mixins for ES6 classes, transpiled with babel
- How do I support jasmine and es6 syntax in Visual studio Code?
- can es6 class have public properties as well as functions?
- is there any way to obtain a reference to (and use) an es6/2015 import in the same expression?
- ES6 classes with Angular 1 DI issue with $inject
- Recursive Tree Walk with ES6 Promise
- Do I have to call super.componentDidUpdate in React?
- How to check if a variable is an ES6 class declaration?
- The this-variable is the Window object or undefined in the then-method of a promise
- Webstorm: Debugging Mocha tests written in ES6
Related Questions in INTERPRETER
- javascript nested loops waiting for user input
- Perl Command Line Interpreter crashing on exit
- Do JavaScript interpreters set all variables to undefined
- Parallel Interpreter For "Treehugger" Programming Language Not Functioning As Intended
- Eclipse, PyDev "Project interpreter not specified”
- Online Python interpreter? Internet explorer 8
- Why does the Lua interactive interpreter stop letting me type things in?
- How Scheme evaluates the man or boy test?
- Implementing reference counting in a stack-based approach in C
- Executing Parsed function calls in Haskell
- Handling recursion in scala's scheme interpreter
- MS Visual Studio-Python Environment-Adding an interpreter- "+ Custom..." greyed out
- Language lexing: better performance to lex a string all at once or individually?
- What is the difference between interpreter and mediator design pattern?
- Jint extremely slow with strings
Related Questions in ECMA
- What is special about .NET primitive types?
- Do javascript numbers follow IEEE 754 double precision?
- Standard Data Types
- How to allow '@' keyword in Javascript
- get instance of load() function in nashorn
- Increment or decrement a value in react array while mapping
- In browsers + Node, what is the scope of a module?
- How to check object is present in JSON or not Using Javascript
- What does mean for loop with one semicolon?
- JS Regex for Parsing SGF (Meta)data
- JS string destructuring: rest parameter returning inconsistent data
- Is there a way to create local scope variable names from all of an object's properties without listing the property names?
- Validation rule for object like array
- When JS code from different sources (Scripts or Modules) must shares the same Realm object?
- @typescript-eslint/parser parserOptions.ecmaVersion ignored / not linting
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
The
@is used as a decorator in a new proposed feature for JavaScript. To use it you need to use a preprocessor like Babel. It is also available in typescript and widely used in Angular2. Example:Decorators will not work by default on Babel, you can find information on enabling them here.
Edit: Whether you consider
@myDecorator('myValue')as@being part of the function name or not, I think we can all acknowledge that it would look this way to those new to the language.Related Links:
https://medium.com/google-developers/exploring-es7-decorators-76ecb65fb841 https://cabbageapps.com/fell-love-js-decorators/