What is the javascript expression?
This article will explain in detail what the javascript expression is. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Javascript expressions are: 1, arithmetic expression; 2, string expression; 3, main expression; 4, array and object initializer expression; 5, logical expression; 6, left expression; 7, attribute access expression; 8, object creation expression; 9, function definition expression; 10, calling expression, etc.
This article operating environment: Windows7 system, javascript1.8.5 version, DELL G3 computer
An expression is a unit of code that can be evaluated and resolved to a value. Expressions in JS can be divided into several categories.
Arithmetic expression
String expression
Main expression
Array and object initializer expressions
Logical expression
Left expression
Attribute access expression
Object creation expression
Function definition expression
Invocation expression
Arithmetic expression
Under this category, take all expressions that evaluate to numbers:
1 / 2i++i-= 2i * 2
String expression
Expression that evaluates to a string:
'A'+ 'string'
Main expression
Under this category, variable references, literals, and constants:
20.02'something'truefalsethis / / the current objectundefinedi / / where i is a variable or a constant
There are also some language keywords:
Functionclassfunction* / / the generator functionyield / / the generator pauser/resumeryield* / / delegate to another generator or iteratorasync function* / / async function expressionawait / / async function pause/resume/wait for completion/pattern/i / / regex () / / grouping
Array and object initializer expressions
[] / / array literal {} / / object literal [1,2,3] {a: 1, b: 2} {a: {b: 1}}
Logical expression
Logical expressions use logical operators and resolve to Boolean values:
A & & ba | | bachela
Left expression
New / / create an instance of a constructorsuper / / calls the parent constructor...obj / / expression using the spread operator
Attribute access expression
Object.property / / reference a property (or method) of an objectobject [property] object ['property']
Object creation expression
New object () new a (1) new MyRectangle ('name', 2, {a: 4})
Function definition expression
Function () {} function (a, b) {return a * b} (a, b) = > a * ba = > a * 2 () = > {return 2}
Invocation expression
Syntax for calling a function or method
A.X (2) window.resize () on "what is a javascript expression" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.