DEV Community

Discussion on: What are examples of expression statements in JavaScript?

Collapse
 
kallmanation profile image
Nathan Kallman

An expression in Javascript (and pretty much all languages, with variation) at the most basic level is just "anything that takes on a value".

So the number 42 or the string "Hello world" or 7 + 3 because they all "take on" a value (42, Hello world, and 10).

As you can tell from this definition, almost everything is an expression. The only other "type" of thing are statements, which there's a more limited number of (depending on language). Things like if / else in Javascript or for because these things don't take on values (you couldn't write something like let variable = if (true) { ... }).

Collapse
 
pandaquests profile image
Panda Quests

In Kotlin you can ...