1

After reading this SE Discussion a question pops up. Why jquery defined two methods for the same purpose? Is there any purpose I missed?

Don't know this belongs to a wiki discussion. If so please guide me to change this so.

4 Answers 4

1

I would guess someone just didn't think it through, unless perhaps the earliest versions had some reason. I could only find source back to 1.2.6, and it is unchanged from the current version.

EDIT: It seems to have been unchanged since version 1.0.1.

The documentation for .size() suggests that it should not be used.

You should use the .length property instead, which is slightly faster.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your efforts. If we think it is confusing, should we raise bug/correction request in jquery official forum/bug tracking system? Or need more research?
@rajakvk - The best you could probably hope for would be some additional clarification in the documentation. I would doubt it will be removed from the API at this point, though. If I as to guess, I'd say that the request would be marked as "invalid" or perhaps "low priority" at best. Couldn't hurt to try though. :o)
1

length is a property inherit from javascript

size() is a method

Comments

0

size returns length. Length is a bit faster.

1 Comment

Length is faster because its a core javascript method , isn't it?
0

"most likely implemented to abstract away from the possibility of the length property being changed"

2 Comments

oh... Is there any proposal to change length property in near future?
don't know ... I'm quoting someone else's answer as it seems the most reasonable explanation of the design decision

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.