11.5. Appendix E: The standard functionalities offered by any JavaScript /ECMAScript compliant engine

<< Click to Display Table of Contents >>

Navigation:  11. Appendix >

11.5. Appendix E: The standard functionalities offered by any JavaScript /ECMAScript compliant engine

 

The next pages list the built-in global constants, functions, and objects provided by any standard JavaScript compliant language. In the next appendix (section 11.6), we will see the built-in functionalities that are specific to Anatella.

 

Constants of the global object

NaN

IEEE 754 Not-a-Number (NaN) value

Infinity

Positive infinity (+∞)

undefined  

Default value for uninitialized variables

 

 

Functions of the global object

print(x)

Prints a value in the Anatella log window

eval(str)

Executes an JavaScript program

parseInt(str, base)

Converts a string to an integer value

parseFloat(str)

Converts a string to a floating-point value

isNaN(n)

Returns true if n is NaN

isFinite(n)

Returns true if n is a number other than NaN, +∞, or -∞

decodeURI(str)

Converts an 8-bit-encoded URI to Unicode

decodeURIComponent(str)

Converts an 8-bit-encoded URI component to Unicode

encodeURI(str)

Converts a Unicode URI to an 8-bit-encoded URI

encodeURIComponent(str)

Converts a Unicode URI component to 8-bit-encoded

Escape()

Encodes a string

Unescape()

Decodes an encoded string

Number()

Converts an object's value to a number

String()

Converts an object's value to a string

 

 

Classes (Constructors)

Object

Provides functionality common to all objects

Function

Encapsulates an JavaScript function

Array

Represents a resizable vector of items

String

Stores a Unicode string

Boolean

Stores a Boolean value (true or false)

Number

Stores a floating-point number. Provide conversion

between Strings and the primitive numeric value.

Date

Stores a date and time

RegExp

Provides regular expression pattern matching

Error

Base type for error types

EvalError

Raised when using eval() wrongly

RangeError

Raised when a numeric value is outside the legal range

ReferenceError

Raised when trying to access an undefined variable

SyntaxError

Raised when a syntax error is detected by eval()

TypeError

Raised when an argument has the wrong type

URIError

Raised when URI parsing fails

 

 

Static Object (always accessible)

Math

Provides mathematical constants and functions

 

 

Properties of the Math Object

E

Returns Euler's number (approx. 2.718)

LN2

Returns the natural logarithm of 2 (approx. 0.693)

LN10

Returns the natural logarithm of 10 (approx. 2.302)

LOG2E

Returns the base-2 logarithm of E (approx. 1.442)

LOG10E

Returns the base-10 logarithm of E (approx. 0.434)

PI

Returns PI (approx. 3.14159)

SQRT1_2

Returns the square root of 1/2 (approx. 0.707)

SQRT2

Returns the square root of 2 (approx. 1.414)

 

 

Methods of the Math Object

abs(x)

Returns the absolute value of x

acos(x)

Returns the arccosine of x, in radians

asin(x)

Returns the arcsine of x, in radians

atan(x)

Returns the arctangent of x as a numeric value between -PI/2 and PI/2 radians

atan2(y,x)

Returns the arctangent of the quotient of its arguments

ceil(x)

Returns x, rounded upwards to the nearest integer

cos(x)

Returns the cosine of x (x is in radians)

exp(x)

Returns the value of Ex

floor(x)

Returns x, rounded downwards to the nearest integer

log(x)

Returns the natural logarithm (base E) of x

max(x,y,z,…,n)

Returns the number with the highest value

min(x,y,z,…,n)

Returns the number with the lowest value

pow(x,y)

Returns the value of x to the power of y

random

Returns a random number between 0 and 1

round(x)

Rounds x to the nearest integer

sin(x)

Returns the sine of x (x is in radians)

sqrt(x)

Returns the square root of x

tan(x)

Returns the tangent of an angle

 

 

Properties of the Number Class

MAX_VALUE

Returns the largest number possible in JavaScript

MIN_VALUE

Returns the smallest number possible in JavaScript

NEGATIVE_INFINITY

Represents negative infinity (returned on overflow)

POSITIVE_INFINITY

Represents infinity (returned on overflow)

 

 

Methods of the Number Class

toExponential(x)

Converts a number into an exponential notation

toFixed(x)

Formats a number with x numbers of digits after the decimal point

toprecision(x)

Formats a number to x length

toString()

Converts a Number object to a string

valueOf()

Returns the primitive value of a Number object

 

 

Methods of the Date Class

getDate()

Returns the day of the month (from 1-31)

getDay()

Returns the day of the week (from 0-6)

getFullYear()

Returns the year (four digits)

getHours()

Returns the hour (from 0-23)

getMilliseconds()

Returns the milliseconds (from 0-999)

getMinutes()

Returns the minutes (from 0-59)

getMonth()

Returns the month (from 0-11)

getSeconds()

Returns the seconds (from 0-59)

getTime()

Returns the number of milliseconds since midnight Jan 1, 1970

getTimezoneOffset()

Returns the time difference between GMT and local time, in minutes

getUTCDate()

Returns the day of the month, according to universal time
(from 1-31)

getUTCDay()

Returns the day of the week, according to universal time (from 0-6)

getUTCFullYear()

Returns the year, according to universal time (four digits)

getUTCHours()

Returns the hour, according to universal time (from 0-23)

getUTCMilliseconds()

Returns the milliseconds, according to universal time (from 0-999)

getUTCMinutes()

Returns the minutes, according to universal time (from 0-59)

getUTCMonth()

Returns the month, according to universal time (from 0-11)

getUTCSeconds()

Returns the seconds, according to universal time (from 0-59)

getYear()

Deprecated. Use the getFullYear() method instead

parse()

Parses a date string and returns the number of milliseconds since midnight of January 1, 1970

setDate()

Sets the day of the month (from 1-31)

setFullYear()

Sets the year (four digits)

setHours()

Sets the hour (from 0-23)

setMilliseconds()

Sets the milliseconds (from 0-999)

setMinutes()

Set the minutes (from 0-59)

setMonth()

Sets the month (from 0-11)

setSeconds()

Sets the seconds (from 0-59)

setTime()

Sets a date and time by adding or subtracting a specified number of milliseconds to/from midnight January 1, 1970

setUTCDate()

Sets the day of the month, according to universal time (from 1-31)

setUTCFullYear()

Sets the year, according to universal time (four digits)

setUTCHours()

Sets the hour, according to universal time (from 0-23)

setUTCMilliseconds()

Sets the milliseconds, according to universal time (from 0-999)

setUTCMinutes()

Set the minutes, according to universal time (from 0-59)

setUTCMonth()

Sets the month, according to universal time (from 0-11)

setUTCSeconds()

Set the seconds, according to universal time (from 0-59)

setYear()

Deprecated. Use the setFullYear() method instead

toDateString()

Converts the date portion of a Date object into a readable string

toGMTString()

Deprecated. Use the toUTCString() method instead

toLocaleDateString()

Returns the date portion of a Date object as a string, using locale conventions

toLocaleTimeString()

Returns the time portion of a Date object as a string, using locale conventions

toLocaleString()

Converts a Date object to a string, using locale conventions

toString()

Converts a Date object to a string

toTimeString()

Converts the time portion of a Date object to a string

toUTCString()

Converts a Date object to a string, according to universal time

UTC()

Returns the number of milliseconds in a date string since midnight of January 1, 1970, according to universal time

valueOf()

Returns the primitive value of a Date object

 

 

Properties of the Array Class

length

Sets or returns the number of elements in an array

 

 

Methods of the Array class

concat()

Joins two or more arrays, and returns a copy of the joined arrays

join()

Joins all elements of an array into a string

pop()

Removes the last element of an array, and returns that element

push()

Adds new elements to the end of an array, and returns the new length

reverse()

Reverses the order of the elements in an array

shift()

Removes the first element of an array, and returns that element

slice()

Selects a part of an array, and returns the new array

sort()

Sorts the elements of an array

splice()

Adds/Removes elements from an array

toString()

Converts an array to a string, and returns the result

unshift()

Adds new elements to the beginning of an array, and returns the new length

valueOf()

Returns the primitive value of an array

 

 

Properties of the String Class

length

Sets or returns the number of elements in an array

 

 

Methods of the String class

charAt()

Returns the character at the specified index

charCodeAt()

Returns the Unicode of the character at the specified index

concat()

Joins two or more strings, and returns a copy of the joined strings

fromCharCode()

Converts Unicode values to characters

indexOf()

Returns the position of the first found occurrence of a specified value in a string

lastIndexOf()

Returns the position of the last found occurrence of a specified value in a string

match()

Searches for a match between a regular expression and a string, and returns the matches

replace()

Searches for a match between a substring (or regular expression) and a string, and replaces the matched substring with a new substring

search()

Searches for a match between a regular expression and a string, and returns the position of the match

slice()

Extracts a part of a string and returns a new string

split()

Splits a string into an array of substrings

substr()

Extracts the characters from a string, beginning at a specified start position, and through the specified number of character

substring()

Extracts the characters from a string, between two specified indices

toLowerCase()

Converts a string to lowercase letters

toUpperCase()

Converts a string to uppercase letters

valueOf()

Returns the primitive value of a String object

 

 

Properties of the RegExp Class

global

Specifies if the "g" modifier is set

ignoreCase

Specifies if the "i" modifier is set

lastIndex

The index at which to start the next match

multiline

Specifies if the "m" modifier is set

source

The text of the RegExp pattern

 
 

Methods of the RegExp Class

compile()

Compiles a regular expression

exec()

Tests for a match in a string. Returns a result array

test()

Tests for a match in a string. Returns true or false