Read object using for of in javascript

     for of loop was introduced in ES6 which allows you to easily iterate over elements of an collection.for of iterates over the values of elements of a collection not the keys. A collection can be an array, set, list, custom collection object etc.

     Earlier to ES6 we had to use for loop or Array’s foreach loop to walk through elements of an collection. ES6 introduced a new way for iteration.

     The following example is help you to read all the value from objects.

Syntax

    for (variable of array_or_object)

    {

       Statements;

    }


Example

    for(i of ar_ob)

      {

        debugger;

        alert("Name : "+i.name);

        alert("Mark : "+i.mark);

      }




Example Program:- (Editor)


Editor is Loading...

Advertisement



Tags:
Read object value using javascript in allinworld99, allinworld99 to get the values of object, how to get the object value in allinworld99.

0 nhận xét:

Đăng nhận xét