
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
Why doesn't JavaScript have a goto statement?
JavaScript has a goto statement, which is a reserved keyword. It isn’t popular since it is not needed in JavaScript. Generally, it isn’t considered a good practice to use a goto statement.
Using goto with JavaScript preprocessing is still considered good as shown below −
var a = 0; [lbl] beginning: console.log("Demo Text!"); a++; if(i < 424) goto beginning;
The above code gets translated like the following −
var a = 0; beginning: while(true) { console.log("Demo Text!"); a++; if(i < 424) continue beginning; break; }
- Related Articles
- Why doesn't JavaScript support multithreading?
- Why an interface doesn't have a constructor whereas an abstract class have a constructor in Java?
- Python3 - Why loop doesn't work?
- PHP goto Statement
- How can I use goto statement in JavaScript?
- Why milk doesn't contain Vitamin C?
- Why doesn't MySQL support millisecond / microsecond precision?
- Why doesn't C++ support functions returning arrays
- Why Black hole doesn\'t emit the light?
- Why dispersion doesn't occur in glass slab?
- goto statement in C/C++
- Why does C++ require a cast for malloc() but C doesn't?
- How a magnet attracts iron ? And it doesn't attract insulator. Why?
- Why JavaScript 'var null' throw an error but 'var undefined' doesn't?
- C program to explain the goto statement

Advertisements