---
title: toRange()
framework: javascriptcore
role: symbol
role_heading: Instance Method
path: javascriptcore/jsvalue/torange()
---

# toRange()

Converts the value to a range.

## Declaration

```swift
func toRange() -> NSRange
```

## Return Value

Return Value A range representation of the value.

## Discussion

Discussion This method treats the value as a JavaScript object, reading the values of its location and length properties using the toDouble() method and creating a NSRange structure from the result. If the value is not a JavaScript object or does not have the appropriate properties, the resulting range is invalid.

## See Also

### Reading and Converting JavaScript Values

- [toObject()](javascriptcore/jsvalue/toobject().md)
- [toObjectOf(_:)](javascriptcore/jsvalue/toobjectof(_:).md)
- [toBool()](javascriptcore/jsvalue/tobool().md)
- [toDouble()](javascriptcore/jsvalue/todouble().md)
- [toInt32()](javascriptcore/jsvalue/toint32().md)
- [toUInt32()](javascriptcore/jsvalue/touint32().md)
- [toNumber()](javascriptcore/jsvalue/tonumber().md)
- [toString()](javascriptcore/jsvalue/tostring().md)
- [toDate()](javascriptcore/jsvalue/todate().md)
- [toArray()](javascriptcore/jsvalue/toarray().md)
- [toDictionary()](javascriptcore/jsvalue/todictionary().md)
- [toPoint()](javascriptcore/jsvalue/topoint().md)
- [toRect()](javascriptcore/jsvalue/torect().md)
- [toSize()](javascriptcore/jsvalue/tosize().md)
