0

I have a JSON as shown below

var result = [
    {
        "SurCharges": "50"
    },
    {
        "SurCharges": "50"
    },
    {
        "SurCharges": "50"
    }
]

As there are 3 elements present inside the result array

How can i get its length ??

I have tried it this way

But it isn't working

could anybody please help

alert(result[0].length);
2
  • 2
    What about result.length? Commented Aug 27, 2014 at 14:21
  • result.length or Object.keys(result[0]).length ? Commented Aug 27, 2014 at 14:22

2 Answers 2

1

you can use .lenght

var numberOfElements = result.length;
alert (numberOfElements);
Sign up to request clarification or add additional context in comments.

Comments

1

try this:

alert(result.length);

Comments

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.