1

I am wondering if there is any significance in implementing Circular Queue in javascript, as there is no strict type check. According to my understanding the circular queue implementation needs an array to be of particular length, but there is no length check in javascript.

Can anybody tell me the advantage of circular queue in javascript.

2
  • A circular queue implementation doesn't require an array of a certain length, it requires logic to determine when the queue wraps around. That's a separate issue than the size of the actual backing store. Commented Mar 16, 2014 at 14:44
  • What I meant is when a value is queued from the queue, then in order to check if the queue is empty I need to splice the array, so that the length property of the array gives the correct length. And circular queue means when the rearreaches the end it comes back to the starting point, and for that we need to know the length of the array and for front and rear flag to work correctly, we need to keep the length of the array constant. Commented Mar 16, 2014 at 14:49

1 Answer 1

2

Javascript is a dynamically typed language. If you need to make sure an array has a particular length, check its length at run time.

Sign up to request clarification or add additional context in comments.

1 Comment

Pedantically, typing isn't the issue. E.g., in Java, it's not the type of a reference, but the size of the (array, for the purposes of this discussion) object being referenced.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.