Angularjs Expression: Expressions in AngularJS are used to bind application data to HTML. The expressions are resolved by Angular and the result is returned back to where the expression is written. The expressions in AngularJS are written in double braces: {{ expression }}. They behave similar to ng-bind directives: ng-bind=”expression”.
Example:
<div>
3 + 3= {{3 + 3}}
3 - 3 = {{3 - 3}}
3 * 3 = {{3 * 3}}
3 / 3 = {{3 / 3}}
</div>
JavaScript Expression: If a valid set of literals, variables, operators, and expressions that evaluate to a single value that is an expression. This single value can be a number, a string, or a logical value as depending expression. With the concept, there are two types of expressions.
- Assigned a value to a variable:
x = 11
- Simply have a value:
22 + 11
JavaScript has the following kinds of expressions:
- Arithmetic: These are the expressions which evaluates to a number.
- Logical: These are the expressions which evaluates to true or false.
- String: These are the expressions which evaluates to a character string, for example “Geek” or “987”.
Note: The special keyword null denotes a null value.
Difference between Angular expression and JavaScript expression
| Parameter | Angularjs expression | JavaScript expression |
|---|---|---|
| Context | Angular expressions are evaluated against a scopeobject. | JavaScript expressions are evaluated against the global window. |
| Forgiving | In Angular, expression evaluation is forgiving to undefined and null. | JavaScript expression try to evaluate undefined properties generates ReferenceError or TypeError. |
| Control Flow Statements | Control flow statements cannot be used in angularjs expressions,i.e,loop,conditional or exception | Control flow statements can be used in JavaScript expressions |
| Function Declarations | Angular Expressions do not allow function declaration,not even inside ng-init directive. | function declaration is allowed in JavaScript expressions |
| Bitwise, Comma, And Void Operators | In an Angular expression Bitwise, , or void operators connot be used. | You can use Bitwise, , or void operators in an JavaScript expression. |
| Filter | Angular expressions can work with filter | JavaScript expressions do not work with filter |
| One time binding | One time binding is supported by AngularJS. To create one time binding use :: expression. | JavaScript expression do not allow one time binding. |
Recommended Posts:
- AngularJS | Expressions
- JavaScript | Regular Expressions
- JavaScript | Immediately Invoked Function Expressions (IIFE)
- PHP | Regular Expressions
- Ruby | Regular Expressions
- Regular Expressions in Scala
- Output of PHP programs | Set 1 (Regular Expressions)
- Perl - Use of Capturing in Regular Expressions
- Overuse of lambda expressions in Python
- How to convert ereg expressions to preg in PHP ?
- Difference between Angular and AngularJS
- Difference between NodeJS and AngularJS
- Difference between Bootstrap and AngularJS
- Difference between VueJS and AngularJS
- What's the difference between ng-pristine and ng-dirty in AngularJS?
- What is the difference between $watch and $observe in AngularJS ?
- Difference between declarations and entryComponents in AngularJS
- Difference between ng-container and ng-template in AngularJS
- Difference between Template and TemplateURL in AngularJS
- What is the Difference between Constructor and ngOnInit in AngularJS ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


