Nitin Choudhary
What is the difference between size and length of jQuery?
By Nitin Choudhary in JQuery on Jan 20 2015
  • Nitin Choudhary
    Jan, 2015 20

    Size and length both returns the number of element in an object. But length is faster than the size because length is a property and size is a method.

    • 4
  • Md. Raskinur Rashid
    Jan, 2015 28

    Agree with Mr. Nitin.In addition you can test from here : http://jsperf.com/size-vs-length

    • 2
  • Munesh Sharma
    Jan, 2015 29

    jQuery .size() method returns number of element in the object. But it is not preferred to use the size()method as jQuery provide .length property and which does the same thing. But the .length property is preferred because it does not have the overhead of a function call

    • 1
  • Bidyasagar Mishra
    Jul, 2019 12

    size and method both returns the same legth but length is faster than size coz size is a method

    • 0
  • Tekesh Bisen
    Jun, 2017 22

    jQuery .size() and .length both return the number of elements in the jQuery object.Size() and length in jQuery both returns the number of element in an object but length is faster than the size because length is a property and size is a method and length property does not have the overhead of a function call.

    • 0
  • Tekesh Bisen
    Jun, 2017 22

    jQuery .size() and .length both return the number of elements in the jQuery object.Size() and length in jQuery both returns the number of element in an object but length is faster than the size because length is a property and size is a method and length property does not have the overhead of a function call.

    • 0
  • Sourav Basak
    Sep, 2015 15

    jQuery .size() and .length both return the number of elements in the jQuery object.Size() and length in jQuery both returns the number of element in an object but length is faster than the size because length is a property and size is a method and length property does not have the overhead of a function call.source: http://www.namasteui.com/difference-between-size-and-length-of-jquery/

    • 0
  • Vaibhav Salwe
    May, 2015 30

    Both size and length return number of character but compare to size, length is fast beacuse size is method and length is property.

    • 0
  • Kml Surani
    May, 2015 8

    Size and length both returns the number of element in an object. But length is faster than the size because length is a property and size is a method.

    • 0
  • Munesh Sharma
    Mar, 2015 30

    http://stackoverflow.com/questions/2738352/jquery-size-method-vs-length-attribute

    • 0
  • Navin Kumar
    Feb, 2015 27

    Size is a method in jquery . It returns number of element in Jquery object. Both size and length return number of element. Size is a method and length is a property so length preferred over size to avoid method call overhead. for Example

    • A
    • B
    alert( "Size: " + $( "li" ).size() ); Result : Size:2alert( "Size: " + $( "li" ).length ); Result Size: 2

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS