Nemeth Attila Nemeth Attila - 1 year ago 47
Javascript Question

How to get array size which is inside an object?

I have an array which contains objects like this:

dataSet = [{question:"",options:[{subject:"",teacher:""}]}]

How can I get the length of the options array?

Answer Source

dataSet itself an array. So get the first index of it and then length of options in it like following.

var dataSet = [{question:"", options:[{subject:"",teacher:""}]}]