setValue()

Sets the range value between the minimum and maximum of a specified `Range` object

Range.prototype.setValue()

The method setValue() sets the range value between the minimum and maximum of a specified Range object.

If the given value is not within range, it's not set.

range.class.ts
public setValue(value: number): this {
  this.value = value;
  return this;
}

Parameters

value:number

The value of number type to set.

Return type

Returns

The return value is the Range instance.

Example usage

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

// Create new instance.
// Returns Range {min: 3, max: 27, value: 10} of Range<3, 27, 3>.
const range = new Range(3, 27, 10, 3);

// Returns 10 of type number | undefined.
range.setValue(300).value;

// Returns 27 of type number | undefined.
range.setValue(27).value;

Last updated