You're viewing the legacy docs. They are deprecated as of May 18, 2016.
These docs are for version 2.4.2 and below of the Javascript SDK. Go to our current docs, or see our Web migration guide.

Version 2.4.2Changelog

Query.limit()

This method is deprecated. Use limitToFirst() and limitToLast() instead.

Generate a new Query object limited to the specified number of children.

If combined with startAt(), the query will include the specified number of children after the starting point. If combined with endAt(), the query will include the specified number of children before the ending point. If not combined with startAt() or endAt(), the query will include the last specified number of children.

// The child_added event will only be
// triggered for the last 500 messages.
var messageListRef = new Firebase('https://samplechat.firebaseio-demo.com/message_list');
lastMessagesQuery = messageListRef.endAt().limit(500);
lastMessagesQuery.on('child_added', function(childSnapshot) { /* handle child add */ });
// The child_added event will only be
// triggered for the first 500 messages.
var messageListRef = new Firebase('https://samplechat.firebaseio-demo.com/message_list');
firstMessagesQuery = messageListRef.startAt().limit(500);
firstMessagesQuery.on('child_added', function(childSnapshot) { /* handle child add */ });
// The child_added event will be triggered for the
// first 50 users with priority of at least 1000.
var usersRef = new Firebase('https://samplechat.firebaseio-demo.com/users');
var usersQuery = usersRef.startAt(1000).limit(50);
usersQuery.on('child_added', function(userSnapshot) { /* handle user */ }));