- int: signed 64bit integer (
int64
in Go) - uint: unsigned 64bit integer (
uint64
in Go) - float: 64bit floating point (
float64
in Go) - bool: boolean (
bool
in Go) - char: character (
rune
in Go) - string: string (
string
in Go) - bytes: byte array (
[]byte
in Go) - array: objects array (
[]Object
in Go) - map: objects map with string keys (
map[string]Object
in Go) - error: an error with a string Name and Message
- undefined: undefined
Note: uGO does not have byte
type. uint
, int
or string
values can be
used to create/modify bytes
values.
int
type Int int64
uint
type Uint uint64
Note: uint values can be represented by adding u
suffix to integer values.
float
type Float float64
bool
type Bool bool
char
type Char rune
string
type String string
bytes
type Bytes []byte
error
type Error struct {
Name string
Message string
Cause error
}
array
type Array []Object
map
type Map map[string]Object
syncMap
type SyncMap struct {
mu sync.RWMutex
Map
}
int | uint | float | bool | char | string | bytes | array | map | error | undefined | |
---|---|---|---|---|---|---|---|---|---|---|---|
int | - | uint64(v) | float64(v) | !IsFalsy() | rune(v) | strconv | X | X | X | String() | X |
uint | int64(v) | - | float64(v) | !IsFalsy() | rune(v) | strconv | X | X | X | String() | X |
float | int64(v) | uint64(v) | - | !IsFalsy() | rune(v) | strconv | X | X | X | String() | X |
bool | 1 / 0 | 1 / 0 | 1.0 / 0.0 | - | 1 / 0 | "true" / "false" | X | X | X | String() | X |
char | int64(v) | uint64(v) | float64(v) | !IsFalsy() | - | string(v) | X | X | X | String() | X |
string | strconv | strconv | strconv | !IsFalsy() | utf8. DecodeRuneInString(v) | - | []byte(v) | X | X | String() | X |
bytes | X | X | X | !IsFalsy() | X | string(v) | - | X | X | String() | X |
array | X | X | X | !IsFalsy() | X | String() | X | - | X | String() | X |
map | X | X | X | !IsFalsy() | X | String() | X | X | - | String() | X |
error | X | X | X | X | X | String() | X | X | X | - | X |
undefined | X | X | X | !IsFalsy() | X | String() | X | X | X | X | - |
- X: No conversion. Conversion function will throw runtime error, TypeError.
- strconv: converted using Go's conversion functions from
strconv
package. - IsFalsy(): use Object.IsFalsy() function.
- String(): use
Object.String()
function.
Object.IsFalsy()
interface method is used to determine if a given value
should evaluate to false
(e.g. for condition expression of if
statement).
- int:
v == 0
- uint:
v == 0
- float:
math.IsNaN(v)
- bool:
!v
- char:
v == 0
- string:
len(v) == 0
- bytes:
len(v) == 0
- array:
len(v) == 0
- map:
len(v) == 0
- error:
true
(error is always falsy) - undefined:
true
(undefined is always falsy)
See builtins for conversion and type checking functions