Published Mar 17 2018
Under this category go all expressions that evaluate to a number:
1 / 2
i++
i -= 2
i * 2
Expressions that evaluate to a string:
'A ' + 'string'
Under this category go variable references, literals and constants:
2
0.02
'something'
true
false
this //the current object
undefined
i //where i is a variable or a constant
but also some language keywords:
function
class
function* //the generator function
yield //the generator pauser/resumer
yield* //delegate to another generator or iterator
async function* //async function expression
await //async function pause/resume/wait for completion
/pattern/i //regex
() // grouping
[] //array literal
{} //object literal
[1,2,3]
{a: 1, b: 2}
{a: {b: 1}}
Logical expressions make use of logical operators and resolve to a boolean value:
a && b
a || b
!a
new //create an instance of a constructor
super //calls the parent constructor
...obj //expression using the spread operator
See the spread operator tutorial
object.property //reference a property (or method) of an object
object[property]
object['property']
new object()
new a(1)
new MyRectangle('name', 2, {a: 4})
function() {}
function(a, b) { return a * b }
(a, b) => a * b
a => a * 2
() => { return 2 }
The syntax for calling a function or method
a.x(2)
window.resize()
I wrote an entire book on this topic 👇
I also got a super cool course 👇
© 2023 Flavio Copes
using
Notion to Site.
Follow on Twitter
Solopreneur? Wannabe? Adventure awaits