Examveda
Examveda

Consider the following code snippet
function tail(o) 
{ 
    for (; o.next; o = o.next) ;
    return o;
}
Will the above code snippet work? If not, what will be the error?

A. No, this will throw an exception as only numerics can be used in a for loop

B. No, this will not iterate

C. Yes, this will work

D. No, this will result in a runtime error with the message “Cannot use Linked List”

Answer: Option C

Solution(By Examveda Team)

The above code uses a for loop to traverse a linked list data structure and return the last object in the list. This will perfectly work.

This Question Belongs to Javascript >> Basic And Variables

Join The Discussion

Related Questions on Basic and Variables