# ★ Constructor

## `Range()`

Creates the [`Range`](/range-1/range/overview.md) instance with a range of the given required [`min`](#min-min), [`max`](#max-max) and optional current [`value`](#value-number), [`step`](#step-step-1-asstep).

{% code title="range.class.ts" %}

```typescript
constructor(min: Min, max: Max, value?: number, step: Step = 1 as Step) {
  this.#maximum = new Maximum(max);
  this.#minimum = new Minimum(min);
  this.#step = step;
  // Sets the range value between the given `min` and `max`.
  this.value = value;
  // Define the `min` and `max` property.
  Object.defineProperties(this, {
    min: {
      value: min,
      enumerable: true,
      writable: false,
    },
    max: {
      value: max,
      enumerable: true,
      writable: false,
    },
  });
}
```

{% endcode %}

### Parameters

#### `min:`[<mark style="color:green;">`Min`</mark>](/range-1/range/generic-type-variables.md#range-less-than-min-max-step-greater-than)

The **minimum** range of generic type variable [`Min`](/range-1/range/generic-type-variables.md#range-less-than-min-max-step-greater-than) to set with a new [`Range`](/range-1/range/overview.md) instance.

#### `max:`[<mark style="color:green;">`Max`</mark>](/range-1/range/generic-type-variables.md#range-less-than-min-max-step-greater-than-1)

The **maximum** range of generic type variable [`Max`](/range-1/range/generic-type-variables.md#range-less-than-min-max-step-greater-than-1) to set with a new [`Range`](/range-1/range/overview.md) instance.

#### `value?:`[<mark style="color:green;">`number`</mark>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)

The optional value of the [`number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) type between the given [`min`](#min-min) and [`max`](#max-max) specifies the default value of a new [`Range`](/range-1/range/overview.md) instance.

#### `step:`[<mark style="color:green;">`Step`</mark>](/range-1/range/generic-type-variables.md#range-less-than-min-max-step-greater-than-2)=`1 as`[<mark style="color:green;">`Step`</mark>](/range-1/range/generic-type-variables.md#range-less-than-min-max-step-greater-than-2)

Optional step of generic type variable [`Step`](/range-1/range/generic-type-variables.md#stepextendsnumber-1) to set with a new [`Range`](/range-1/range/overview.md) instance, by default **`1`**.

{% hint style="info" %}
The step is used by the [`range`](/range-1/range/accessors/get-range.md) accessor, [`getRange()`](/range-1/range/methods/getrange.md) , [`getRangeOfStep()`](/range-1/range/methods/getrangeofstep.md) and [`stepByStep()`](/range-1/range/methods/stepbystep.md) methods to return the entire range and also by the [`valueDown()`](/range-1/range/methods/valuedown.md), [`valueUp()`](/range-1/range/methods/valueup.md) methods to respectively decrement, increment range value.
{% endhint %}

## Example usage

```typescript
// Example usage.
import { Range } from '@angular-package/range';

// Returns Range {min: 4, max: 27} of Range<4, 27, 1>
new Range(4, 27);

// Returns Range {min: 4, max: 27, value: 27} of Range<4, 27, 1>
new Range(4, 27, 27);

// Returns Range {min: 4, max: 27, value: 5} of Range<4, 27, 1.5>
new Range(4, 27, 5, 1.5);
```


---

# 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://docs.angular-package.dev/range-1/range/constructor.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.
