10
Reply

What is the difference between size and length of jQuery?

Nitin Choudhary

Nitin Choudhary

Jan 20, 2015
5.9k
1

    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.

    Nitin Choudhary
    January 20, 2015
    4

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

    Md. Raskinur Rashid
    January 28, 2015
    2

    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

    Munesh Sharma
    January 29, 2015
    1

    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.

    Tekesh Bisen
    June 22, 2017
    0

    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.

    Tekesh Bisen
    June 22, 2017
    0

    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/

    Sourav Basak
    September 15, 2015
    0

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

    Vaibhav Salwe
    May 30, 2015
    0

    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.

    Kml Surani
    May 08, 2015
    0

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

    Munesh Sharma
    March 30, 2015
    0

    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

    Navin Kumar
    February 27, 2015
    0