InterviewHubPRO
Section Overview
Q252

Question 252 of 521

Part 4: Prototypes, Object Methods & Event Loop (174 - 253)

48%
JavaScript Internals (521 Qs)•Part 4: Prototypes, Object Methods & Event Loop (174 - 253)

What is an empty statement and purpose of it

The empty statement is a semicolon (;) indicating that no statement will be executed, even if JavaScript syntax requires one. Since there is no action with an empty statement you might think that it's usage is quite less, but the empty statement is occasionally useful when you want to create a loop that has an empty body. For example, you can initialize an array with zero values as below,

javascript
  // Initialize an array a
  for (let i = 0; i < a.length; a[i++] = 0);