EDDYMENS

Last updated 2022-11-05 03:50:45

What Is Semantic?

Definition

Semantics unlink syntax [→] concerns itself with the intended meaning of any written code.

So even if a piece of code is correct in terms of syntax (grammar) it might not lead to the intended outcome. At that point, we say we have a semantic error or bug [→].

Use Cases and Examples

01: // An infinite loop 02: while (true) { 03: console.log("This text will repeat itself forever"); 04: }

The code above is valid in terms of syntax so it will run, the problem though is that the while loop will continue to run forever since the condition true will remain true forever. The program will eventually crash. It's unlikely this is the kind of outcome a developer is looking for.

Here is another article you might like 😊 "Diary Of Insights: A Documentation Of My Discoveries"