Skip to main content
InterviewHubPRO
Section Overview
Q252

Question 252 of 536

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

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

What is an empty statement and purpose of it

junior LevelMost AskedCode ExampleEvent LoopPrototypes

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);