# takeLast

#### signature: `takeLast(count: number): Observable`

## Emit the last n emitted values before completion

***

💡 If you want only the last emission from multiple observables, on completion of multiple observables, try [forkJoin](/learn-rxjs/operators/combination/forkjoin.md)!

***

### Examples

**Example 1: take the last 2 emitted values before completion**

( [StackBlitz](https://stackblitz.com/edit/typescript-zss7oo?file=index.ts\&devtoolsheight=100) )

```js
// RxJS v6+
import { of } from 'rxjs';
import { takeLast } from 'rxjs/operators';

const source = of('Ignore', 'Ignore', 'Hello', 'World!');
// take the last 2 emitted values
const example = source.pipe(takeLast(2));
// Hello, World!
const subscribe = example.subscribe(val => console.log(val));
```

### Additional Resources

* [takeLast](https://rxjs-dev.firebaseapp.com/api/operators/takeLast) 📰 - Official docs

***

> 📁 Source Code: <https://github.com/ReactiveX/rxjs/blob/master/packages/rxjs/src/internal/operators/takeLast.ts>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.learnrxjs.io/learn-rxjs/operators/filtering/takelast.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
