JavaScript Expression & Statement


An expression is any valid set of literals, variables, operators that evaluates to a single value.

`${5 + 5}`// 10

`${5 + "javaScript"}`// 5javaScript

`${function foo() {}}`// function foo() {}

Additionally anyone can do some operation which can be useful in some cases,

//  so function expression can be evaluated
function getMessage() {
    return "I love JavaScript"

const res = `My message is ${getMessage()}`// My message is I love JavaScript

Functions are First Class Citizen so we can make a call and evaluate them in a string literal expression.


Statements are programming instructions. Statement can end with a semicolon ;.

// example 1; DOM manipulation statement
document.getElementById("header").innerHTML = "Hello Dolly.";

// example 2; single line instruction
`JavaScript is ${true ? 'good' : 'not good'}`

// example 3; assigning statement
let x = 10;

Leave a Comment

Your email address will not be published. Required fields are marked *