Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In programming, what is an expression? [closed]

Tags:

I've Googled this question, and searched on SO, however I can't seem to get a straight answer.

Is this question so basic no-one has thought to ask it yet?

Can someone please explain what exactly an "expression" is in programming.

Also I program primarily in Javascript, if the definition varies in JS could you please also highlight the difference?

like image 991
Rich Avatar asked Aug 26 '13 12:08

Rich


People also ask

What does it mean for an expression to be closed?

A closed expression (or closed formula) refers to a formula that has no free variables [1]. This is also called sentence.

What is a closed equation?

An equation is said to be a closed-form solution if it solves a given problem in terms of functions and mathematical operations from a given generally-accepted set. For example, an infinite sum would generally not be considered closed-form.

What are closures in programming?

A closure is a programming technique that allows variables outside of the scope of a function to be accessed. Usually, a closure is created when a function is defined in another function, allowing the inner function to access variables in the outer one.

What does no closed-form solution mean?

A closed form solution provides an exact answer and one that is not closed form is an approximation, but you can get a non closed form solution as close as to a closed form solution as you want.


1 Answers

In Javascript:

An expression is any valid unit of code that resolves to a value.

Conceptually, there are two types of expressions: those that assign a value to a variable and those that simply have a value.

The expression x = 7 is an example of the first type.
This expression uses the = operator to assign the value seven to the variable x. The expression itself evaluates to seven.

The code 3 + 4 is an example of the second expression type.
This expression uses the + operator to add three and four together without assigning the result, seven, to a variable.

JavaScript has the following expression categories:

  • Arithmetic: evaluates to a number, for example 3.14159. (Generally uses arithmetic operators.)
  • String: evaluates to a character string, for example, "Fred" or "234". (Generally uses string operators.)
  • Logical: evaluates to true or false. (Often involves logical operators.)
  • Object: evaluates to an object. (See special operators for various ones that evaluate to objects.)"

Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators

here is Microsoft's explanation of expressions in .NET

like image 170
VisualBean Avatar answered Oct 29 '22 15:10

VisualBean