Unreachable code and Dead code

As a developer, I believe you have seen much code that existed in the software but it will never reach and executed. At here, we will introduce you the dead code and unreachable code.

Unreachable code
Unreachable code is a piece of code that will never reach and execute through the logic flow.

For example

JAVASCRIPT


Dead code
Dead code is a piece of code that will execute, but never be used at anywhere.

For example:

JAVASCRIPT