# JS Lib

## Overview

This class provides essential JavaScript constants and utility functions like Infinity, NaN, and undefined, along with URI encoding/decoding (encodeURI, decodeURIComponent) and string parsing (parseFloat, parseInt). It includes utilities like isFinite and isNaN for value validation and supports dynamic code evaluation through eval.

## **Returned Types**

[Boolean](/reference/servoycore/dev-api/js-lib/boolean.md),[String](/reference/servoycore/dev-api/js-lib/string.md),[Date](/reference/servoycore/dev-api/js-lib/date.md),[Number](/reference/servoycore/dev-api/js-lib/number.md),[Array](/reference/servoycore/dev-api/js-lib/array.md),[Function](/reference/servoycore/dev-api/js-lib/function.md),[IterableValue](/reference/servoycore/dev-api/js-lib/iterablevalue.md),[Iterator](/reference/servoycore/dev-api/js-lib/iterator.md),[JSON](/reference/servoycore/dev-api/js-lib/json.md),[Map](/reference/servoycore/dev-api/js-lib/map.md),[Math](/reference/servoycore/dev-api/js-lib/math.md),[Namespace](/reference/servoycore/dev-api/js-lib/namespace.md),[QName](/reference/servoycore/dev-api/js-lib/qname.md),[RegExp](/reference/servoycore/dev-api/js-lib/regexp.md),[Set](/reference/servoycore/dev-api/js-lib/set.md),\[Special Operators]\(./special operators.md),[Statements](/reference/servoycore/dev-api/js-lib/statements.md),[XML](/reference/servoycore/dev-api/js-lib/xml.md),[XMLList](/reference/servoycore/dev-api/js-lib/xmllist.md),[BigInt](/reference/servoycore/dev-api/js-lib/bigint.md),[Promise](/reference/servoycore/dev-api/js-lib/promise.md),

## Properties Summarized

| Type                                                     | Name                    | Summary                              |
| -------------------------------------------------------- | ----------------------- | ------------------------------------ |
| [Number](/reference/servoycore/dev-api/js-lib/number.md) | [Infinity](#infinity)   | Numeric value representing infinity. |
| [Number](/reference/servoycore/dev-api/js-lib/number.md) | [NaN](#nan)             | Value representing Not-a-Number.     |
| [Object](/reference/servoycore/dev-api/js-lib/object.md) | [undefined](#undefined) | The value undefined.                 |

## Methods Summarized

| Type                                                       | Name                                                             | Summary                                                                                                      |
| ---------------------------------------------------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| [String](/reference/servoycore/dev-api/js-lib/string.md)   | [decodeURI(encodedURI)](#decodeuri-encodeduri)                   | Decodes a URI previously encoded with encodeURI or another similar routine.                                  |
| [String](/reference/servoycore/dev-api/js-lib/string.md)   | [decodeURIComponent(encodedURI)](#decodeuricomponent-encodeduri) | Decodes a URI component previously created by encodeURIComponent or by a similar routine.                    |
| [String](/reference/servoycore/dev-api/js-lib/string.md)   | [encodeURI(URI)](#encodeuri-uri)                                 | Encodes a URI by replacing certain characters with escape sequences.                                         |
| [String](/reference/servoycore/dev-api/js-lib/string.md)   | [encodeURIComponent(URI)](#encodeuricomponent-uri)               | Encodes a URI component by replacing all special characters with their corresponding UTF-8 escape sequences. |
| [Object](/reference/servoycore/dev-api/js-lib/object.md)   | [eval(expression)](#eval-expression)                             | Evaluates JavaScript code passed as a string.                                                                |
| [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) | [isFinite(n)](#isfinite-n)                                       | Returns true if the given number is a finite number.                                                         |
| void                                                       | [isNaN(value)](#isnan-value)                                     | The NaN property indicates that a value is 'Not a Number'.                                                   |
| [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md) | [isXMLName(name)](#isxmlname-name)                               | Returns true if the given name can be used as a valid name for an XML element or attribute.                  |
| [Number](/reference/servoycore/dev-api/js-lib/number.md)   | [parseFloat(text)](#parsefloat-text)                             | Makes a floating point number from the starting numbers in a given string.                                   |
| [Number](/reference/servoycore/dev-api/js-lib/number.md)   | [parseInt(text)](#parseint-text)                                 | Makes a integer from the starting numbers in a given string in the base specified.                           |
| [Number](/reference/servoycore/dev-api/js-lib/number.md)   | [parseInt(text, radix)](#parseint-text-radix)                    | Makes a integer from the starting numbers in a given string in the base specified.                           |

## Properties Detailed

### Infinity

Numeric value representing infinity.

**Type**\
[Number](/reference/servoycore/dev-api/js-lib/number.md)

**Sample**

```js
Infinity
```

### NaN

Value representing Not-a-Number.

**Type**\
[Number](/reference/servoycore/dev-api/js-lib/number.md)

**Sample**

```js
NaN
```

### undefined

The value undefined.

**Type**\
[Object](/reference/servoycore/dev-api/js-lib/object.md)

**Sample**

```js
undefined
```

## Methods Detailed

### decodeURI(encodedURI)

Decodes a URI previously encoded with encodeURI or another similar routine.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **encodedURI** ;

**Returns:** [String](/reference/servoycore/dev-api/js-lib/string.md)

**Sample**

```js
var str = "http://www.mysite.com/my code.asp?name=[cool]";
var encoded = encodeURI(str);
var decoded = decodeURI(encoded);
application.output(encoded);//http://www.mysite.com/my%20code.asp?name=%5bcool%5d
application.output(decoded);//http://www.mysite.com/my code.asp?name=[cool]
```

### decodeURIComponent(encodedURI)

Decodes a URI component previously created by encodeURIComponent or by a similar routine.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **encodedURI** ;

**Returns:** [String](/reference/servoycore/dev-api/js-lib/string.md)

**Sample**

```js
var str = "my code.asp?name=[cool]";
var encoded = encodeURIComponent(str);
var decoded = decodeURIComponent(encoded);
application.output(encoded); //my%20code.asp%3fname%3d%5bcool%5d
application.output(decoded); //my code.asp?name=[cool]
```

### encodeURI(URI)

Encodes a URI by replacing certain characters with escape sequences.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **URI** ;

**Returns:** [String](/reference/servoycore/dev-api/js-lib/string.md)

**Sample**

```js
var str = "http://www.mysite.com/my code.asp?name=[cool]";
var encoded = encodeURI(str);
var decoded = decodeURI(encoded);
application.output(encoded);//http://www.mysite.com/my%20code.asp?name=%5bcool%5d
application.output(decoded);//http://www.mysite.com/my code.asp?name=[cool]
```

### encodeURIComponent(URI)

Encodes a URI component by replacing all special characters with their corresponding UTF-8 escape sequences.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **URI** ;

**Returns:** [String](/reference/servoycore/dev-api/js-lib/string.md)

**Sample**

```js
var str = "my code.asp?name=[cool]";
var encoded = encodeURIComponent(str);
var decoded = decodeURIComponent(encoded);
application.output(encoded); //my%20code.asp%3fname%3d%5bcool%5d
application.output(decoded); //my code.asp?name=[cool]
```

### eval(expression)

Evaluates JavaScript code passed as a string. Returns the value returned by the evaluated code.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **expression** ;

**Returns:** [Object](/reference/servoycore/dev-api/js-lib/object.md)

**Sample**

```js
eval("var x = 2 + 3;");
application.output(x); // prints: 5.0
```

### isFinite(n)

Returns true if the given number is a finite number.

**Parameters**

* [Number](/reference/servoycore/dev-api/js-lib/number.md) **n** ;

**Returns:** [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md)

**Sample**

```js
application.output(isFinite(1)); // prints: true
application.output(isFinite(Infinity)); // prints: false
application.output(isFinite(isNaN)); // prints: false
```

### isNaN(value)

The NaN property indicates that a value is 'Not a Number'.

**Parameters**

* [Object](/reference/servoycore/dev-api/js-lib/object.md) **value** ;

**Returns:** void

**Sample**

```js
isNaN( value )
```

### isXMLName(name)

Returns true if the given name can be used as a valid name for an XML element or attribute.\
This was implemented by the Rhino engine as part of Ecma-357 which was meanwhile withdrawn.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **name** ;

**Returns:** [Boolean](/reference/servoycore/dev-api/js-lib/boolean.md)

**Sample**

```js
application.output(isXMLName("good_name")); // prints: true
application.output(isXMLName("bad name")); // because of the space, prints: false
```

### parseFloat(text)

Makes a floating point number from the starting numbers in a given string.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **text** ;

**Returns:** [Number](/reference/servoycore/dev-api/js-lib/number.md)

**Sample**

```js
parseFloat('string')
```

### parseInt(text)

Makes a integer from the starting numbers in a given string in the base specified.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **text** ;

**Returns:** [Number](/reference/servoycore/dev-api/js-lib/number.md)

**Sample**

```js
parseInt('0774')
```

### parseInt(text, radix)

Makes a integer from the starting numbers in a given string in the base specified.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **text** ;
* [Number](/reference/servoycore/dev-api/js-lib/number.md) **radix** ;

**Returns:** [Number](/reference/servoycore/dev-api/js-lib/number.md)

**Sample**

```js
parseInt('0774' , 8)
```

***


---

# 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.servoy.com/reference/servoycore/dev-api/js-lib.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.
