Script Functions List
Script Functions
Canvas Scripts
All functions must be used with parentheses
Note: USBs must be formatted in exFAT or FAT32 to be used with the eXT, nXT, and eXT2 series.
Note: when using Storage.Local as a storage location, the Xpanel refers to the path $DATA_PARTITION/home/user
while the simulator refers to the path C:\Users\<user>
.
Alarm
Function | Parameters and Return Value |
Description and Example |
---|---|---|
alarm.createAllCsv(Storage type ) |
Storage type: 1: Storage.Local 2: Storage.Usb 3: Storage.SdCard 4: Storage.Ftp Returns: No return value |
Saves all the messages at the assigned Storage type as a CSV.
|
alarm.createCsv(String label , Storage type )
|
String label: Label used within the alarm settings. Storage type: 1: Storage.Local 2: Storage.Usb 3: Storage.SdCard 4: Storage.Ftp Returns: No return value |
Saves all the alarm messages associated with the String label at the assigned Storage type as a CSV.String label refers to one of the labels within the Alarm Settings. Users can create their own labels or use a preset label.
|
Data Log
Function | Parameters and Return Value |
Description and Example |
---|---|---|
datalog.addRow(String modelName ) |
String modelName: Name of the data log model to target Returns: No return value |
Adds a single row to the specified data log model.
|
datalog.createCsv(String modelName , Storage type ) |
String modelName: Name of the data log model to target Storage type: 1: Storage.Local 2: Storage.Usb 3: Storage.SdCard 4: Storage.Ftp Returns: No return value |
Creates a CSV file of the data log model specified at the designated Storage type .
|
datalog. createCsvForRange( String modelName , Date start , Date end , Storage type ) |
String modelName: Name of the data log model to target Date start: Starting date Date end: Ending date Storage type: 1: Storage.Local 2: Storage.Usb 3: Storage.SdCard 4: Storage.Ftp Returns: No return value |
Creates a CSV file of the data log model specified at the designated Storage type with a set time boundary.
|
datalog.start(String modelName ) |
String modelName: Name of the data log model to target Returns: No return value |
Begins logging for the data log model specified.
|
datalog.stop(String modelName ) |
String modelName: Name of the data log model to target Returns: No return value |
Ends logging for the data log model specified.
|
Driver
Function | Parameters and Return Value |
Description and Example |
---|---|---|
driver.enable(String deviceName ) |
String deviceName: Name of the driver to target Returns: No return value |
Enables the specified device.
|
driver.disable(String deviceName ) |
String deviceName: Name of the driver to target Returns: No return value |
Disables the specified device.
|
Keyboard
Function | Parameters and Return Value |
Description and Example |
---|---|---|
keyboard. launchKeyboard( String tagName )keyboard. launchKeyboard( String tagName , Object properties ) |
String tagName: Name of the tag to set Object properties: Optional parameter List of keyboard style properties
Returns: No return value |
Launches a popup keyboard for user input to set the value of a tag.
|
keyboard. launchKeypad( String tagName )keyboard. launchKeypad( String tagName , Object properties ) |
String tagName: Name of the tag to set Object properties: Optional parameter List of keypad style properties
Returns: No return value |
Launches a numeric popup keypad for user input to set the value of a tag.
|
keyboard. sendKeyEvent( KeyCode keyCode ) |
KeyCode keyCode: Hexadecimal or decimal value of the key Returns: No return value |
Simulates a keystroke for a keycode.
|
Notification
Function | Parameters and Return Value |
Description and Example |
---|---|---|
notification.send(String msg )notification.send( String msg , int dismissInterval ) |
String msg: Message to display int dismissInterval: Optional parameter Amount of time, in milliseconds (ms), before the notification disappears Returns: Unsigned long value |
Sends a popup notification to the screen displaying the specified message and returns an unsigned long unique ID. If dismissInterval is less than 0, the message will display until it is manually dismissed.
|
Page
Function | Parameters and Return Value |
Description and Example |
---|---|---|
page.close(String name ) |
String name: Name of the page Returns: No return value |
Closes the base page with the specified name.
|
page.closeIndex(int index ) |
int index: Number of the page Returns: No return value |
Closes the base page with the specified index number.
|
page.closePopupIndex(int index ) |
int index: Number of the popup page Returns: No return value |
Closes the popup page with the specified index number.
|
page.currentIndex() |
Returns: int value of the index of the currently opened page |
Returns the index of the currently opened page.
|
page.currentName() |
Returns: String value of the name of the currently opened page |
Returns the name of the currently opened page.
|
page.isOpen(String name ) |
String name: Name of the page Returns: Boolean value |
Returns a boolean value, true (1) or false (0), if the base page with the specified name is open.
|
page.isOpenIndex(int index ) |
int index: Number of the page Returns: Boolean value |
Returns a boolean value, true (1) or false (0), if the base page with the specified index is open.
|
page.isOpenPopupIndex(int index ) |
int index: Number of the page Returns: Boolean value |
Returns a boolean value, true (1) or false (0), if the popup page with the specified name is open.
|
page.open(String name ) |
String name: Name of the page Returns: No return value |
Opens the base page with the specified name.
|
page.openIndex(int index ) |
int index: Number of the page Returns: No return value |
Opens the base page with the specified index number.
|
page.openPopupIndex(int index ) |
int index: Number of the popup page Returns: No return value |
Opens the popup page with the specified index number.
|
page.openPrevious() |
Returns: No return value |
Opens the previous base page.
|
Recipe
Function | Parameters and Return Value |
Description and Example |
---|---|---|
recipe. createRecord( String recipe , int id , String name , List<Value> values ) |
String recipe: Recipe database to target int id: ID of the record String name: Name of the record List<Value> values: List of parameter values to store in the record Returns: No return value |
Adds a new record with the given parameters to the recipe database.
|
recipe. deleteRecord( String recipe , int id ) |
String recipe: Recipe database to target int id: ID of the record Returns: No return value |
Deletes an existing record from the recipe database.
|
recipe. exportCsv( String recipe , Storage type , String path ) |
String recipe: Recipe database to target Storage type: 1: Storage.Local 2: Storage.Usb 3: Storage.SdCard 4: Storage.Ftp String path: Refers to where to find the CSV file, relative to the storage location Returns: No return value |
Saves the recipe data in a CSV file at the specified path.
|
recipe. getAllParameters( String recipe ) |
String recipe: Recipe database to target Returns: Array of the current tag values |
Returns an array of the current parameter values from the device (the current tag values).
|
recipe. getParameter( String recipe , int id , int index ) |
String recipe: Recipe database to target int id: ID of the record int index: Parameter index within the record Returns: Value of the record's parameter by the given parameter index |
Returns the value of the record's parameter by the specified parameter index. This is similar to the recipe.getParameterByName() script.
|
recipe. getParameter ByName( String recipe , int id , String name ) |
String recipe: Recipe database to target int id: ID of the record String name: Name of the record parameter Returns: Value of the record's parameter by the given parameter name |
Returns the value of the record's parameter by the specified parameter name. This is similar to the recipe.getParameter() script.
|
recipe. getRecordName( String recipe , int id ) |
String recipe: Recipe database to target int id: ID of the record Returns: String name of the record |
Returns the name of the record in specified recipe database.
|
recipe. getRecordValues( String recipe , int id ) |
String recipe: Recipe database to target int id: ID of the record Returns: Array of parameter values |
Returns an array of the values of the specified record.
|
recipe. importCsv( String recipe , Storage type , String path ) |
String recipe: Recipe database to target Storage type: 1: Storage.Local 2: Storage.Usb 3: Storage.SdCard 4: Storage.Ftp String path: Refers to where to find the CSV file, relative to the storage location Returns: No return value |
Replaces recipe data with the data found in a CSV at the path.
|
recipe.openConfig() |
Returns: No return value |
Opens the recipe config window.
|
recipe.receiveRecord(String recipe , int id ) |
String recipe: Recipe database to target int id: ID of the record Returns: No return value |
Gets the recipe values from a remote device and saves them in the recipe database.
|
recipe.sendRecord(String recipe , int id ) |
String recipe: Recipe database to target int id: ID of the record Returns: No return value |
Sends the values of the specified record in the recipe database to the remote device.
|
recipe. setParameter( String recipe , int id , int index , Value value ) |
String recipe: Recipe database to target int id: ID of the record int index: Parameter index within the record Value value: Value to be input into the parameter Returns: No return value |
Sets the value of the record's parameter by the specified parameter index. This is similar to the recipe.setParameterByName() script.
|
recipe. setParameterByName( String recipe , int id , String name , Value value ) |
String recipe: Recipe database to target int id: ID of the record String name: Parameter name within the record Value value: Value to be input into the parameter Returns: No return value |
Returns the value of the record's parameter by the specified parameter name. This is similar to the recipe.setParameter() script.
|
recipe. setRecord( String recipe , int id , List<Value> values ) |
String recipe: Recipe database to target int id: ID of the record List<Value> values: List of parameter values to store in the record Returns: No return value |
Updates the values of a record.
|
recipe. setRecordId( String recipe , int oldId , int newId ) |
String recipe: Recipe database to target int oldId: ID of the record to update int newId: ID to update the record to Returns: No return value |
Updates the record ID for a record in the specified recipe database.
|
recipe. setRecordName( String recipe , int id , String name ) |
String recipe: Recipe database to target int id: ID of the record String name: Name to change the record to Returns: No return value |
Updates the name of a record from the specified recipe database.
|
Schedule
Function | Parameters and Return Value |
Description and Example |
---|---|---|
schedule.isEnabled(String title ) |
String title: Name of the schedule Returns: Boolean value |
Returns a boolean value, true (1) or false (0), if the schedule is enabled.
|
schedule.setEnabled(String title , boolean enable ) |
String title: Name of the schedule boolean enable: 0: false1: true
Returns: No return value |
Sets the specified schedule to enabled if the value is 1 or disabled if the value is 0.
|
System
Function | Parameters and Return Value |
Description and Example |
---|---|---|
system.audio.playFile(Storage type , String relativePath , boolean async ) |
Storage type: 1: Storage.Local 2: Storage.Usb 3: Storage.SdCard 4: Storage.Ftp 5: Storage.Project String relativePath: Path of the file boolean async: Optional parameter Run asynchronously 0: false1: true
Returns: No return value |
Plays an audio file. If the boolean async parameter is absent, the default value is true.Previously sold CM-eXT07 and CM-nXT07 devices produced before November of 2024 do not support this feature.
|
system.audio.stopFile(Storage type , String relativePath ) |
Storage type: 1: Storage.Local 2: Storage.Usb 3: Storage.SdCard 4: Storage.Ftp 5: Storage.Project String relativePath: Path of the file Returns: No return value |
Stops all audio files. Previously sold CM-eXT07 and CM-nXT07 devices produced before November of 2024 do not support this feature.
|
system.audit.log(String description ) |
String description: Text to be added to the audit log Returns: No return value |
Logs the entered description in the audit log.
|
system.currentUsername() |
Returns: String value of the currently logged-in user's name |
Returns the current username of the current logged-in user. If no user is logged in, an empty String is returned.
|
system. display.brightness() |
Returns: double value |
Returns a double value between 0 and 1 representing the brightness level of the Xpanel. This script will not work in the simulator.
|
system. display.dimDelay() |
Returns: int value |
Returns an int value representing the Xpanel dim delay time, in minutes. This script will not work in the simulator.
|
system. display.enableBacklight( boolean enable ) |
boolean enable: Enable the Xpanel backlight 0: false1: true
Returns: No return value |
Turns the backlight of the Xpanel on (1) or off (0). This script will not work in the simulator. Warning: Do not use this script with the auto-dimming or auto-sleep features. It may cause unintended behavior.
|
system. display.isDimmerEnabled() |
Returns: Boolean value |
Returns a boolean value, true (1) or false (0), if the dimmer setting is enabled. This script will not work in the simulator.
|
system. display.setBrightness( float brightness ) |
float brightness: Brightness level of the Xpanel Returns: No return value |
Sets the specified brightness of the Xpanel. Note: the float brightness parameter must be between 0 and 1, and 0 brightness does not completely turn off the backlight.This script will not work in the simulator.
|
system. display.setDimDelay( int minutes ) |
int minutes: Time until the Xpanel dims Returns: No return value |
Sets the time, in minutes, before the Xpanel dims. Note: if int minutes is negative, the delay is 0.This script will not work in the simulator.
|
system. display.setDimEnabled( boolean enabled ) |
boolean enable: 0: false1: true
Returns: No return value |
Turns the Xpanel dimmer on (1) or off (0). This script will not work in the simulator.
|
system.email.send(Object properties ) |
Object properties: Contents of the email
Returns: No return value |
Sends an email using the SMTP settings.
|
system.execute(String program , Array arguments ) |
String program: The program to run Array arguments: Array of arguments for the program Returns: No return value |
Create a non-blocking asynchronous call for the subprocess of String program with the Array arguments .
|
system.exit() |
Returns: No return value |
Closes the current project and runtime application.
|
system.file.exists(Storage type , String path ) |
Storage type: 1: Storage.Local 2: Storage.Usb 3: Storage.SdCard 4: Storage.Ftp String path: File path Returns: Boolean value |
Returns a boolean value, true (1) or false (0), if the file exists.
|
system.file.isDirectory(Storage type , String path ) |
Storage type: 1: Storage.Local 2: Storage.Usb 3: Storage.SdCard 4: Storage.Ftp String path: Directory path Returns: Boolean value |
Returns a boolean value, true (1) or false (0), if the file path is a directory.
|
system.file.openDialog(Storage type , String path ) |
Storage type: 1: Storage.Local 2: Storage.Usb 3: Storage.SdCard 4: Storage.Ftp String path: Directory path Returns: String value of the file selected |
Returns a String value of the file selected from the storage location.
|
system.file.openPdf(Storage type , String path ) |
Storage type: 1: Storage.Local 2: Storage.Usb 3: Storage.SdCard 4: Storage.Ftp 5: Storage.Project String path: Path to the PDF file Returns: No return value |
Opens a PDF with a separate PDF viewer. This script will not work in the simulator.
|
system.file.saveDialog(Storage type , String path ) |
Storage type: 1: Storage.Local 2: Storage.Usb 3: Storage.SdCard 4: Storage.Ftp String path: Path to the file Returns: String value of the file saved |
Opens a dialog window to save a file at the given path.
|
system.ftp.download(Object config , Storage type , String sourcePath , String targetPath ) |
Object config: FTP server information
Storage type: 1: Storage.Local 2: Storage.Usb 3: Storage.SdCard 4: Storage.Ftp String sourcePath: Source file path String targetPath: Target file path Returns: Boolean value |
Returns a boolean value, true (1) or false (0), if downloading Object config from the FTP server was successful.This script will not work in the simulator.
|
system.ftp.startServer() |
Returns: No return value |
Start a local FTP server. This script will not work in the simulator.
|
system.ftp.stopServer() |
Returns: No return value |
Stop a local FTP server. This script will not work in the simulator.
|
system.ftp.upload(Object config , Storage type , String sourcePath , String targetPath ) |
Object config: FTP server information
Storage type: 1: Storage.Local 2: Storage.Usb 3: Storage.SdCard 4: Storage.Ftp String sourcePath: Source file path String targetPath: Target file path Returns: Boolean value |
Returns a boolean value, true (1) or false (0), if uploading Object config to the FTP server was successful.This script will not work in the simulator.
|
system.hasPermission(String permission ) |
String permission: Permission to check for Returns: Boolean value |
Returns a boolean value, true (1) or false (0), if the currently logged-in user has the specified permission.
|
system.importScript(String scriptName ) |
String scriptName: Script to run Returns: No return value |
Executes the specified script in the current project on the current thread.
|
system.login(String username , String password ) |
String username: Name of the user String password: Optional parameter Password of the user Returns: Boolean value |
Returns a boolean value, true (1) or false (0), if the user could successfully log in to the Identity and Access Management feature.
|
system.logout() |
Returns: No return value |
Logs out the current user from the Identity and Access Management feature.
|
system. openAuthWindow( Object properties ) |
Object properties: Optional parameter Conditions for authenticating a user
Returns: Boolean value |
Opens a dialog window to authenticate a user and returns a boolean value, true (1) or false (0), if the user could successfully log in. If no user is provided, this will authenticate any user that enters their username and password. If the user does not have the listed permissions, they will not be able to log in.
|
system.openConfig() |
Returns: No return value |
Opens the runtime configuration menu.
|
system. openFrameMonitor() |
Returns: No return value |
Opens the frame monitor window. This script will not work in the simulator.
|
system. openLoginWindow( Object properties ) |
Object properties:
Optional parameterConditions for displaying available users or the user type
Returns: No return value |
Opens the login window for the Identity and Access Management feature.
|
system.runScript(String scriptName ) |
String scriptName:
Name of the script to run
Returns: No return value |
Executes the specified script in the current project on a separate thread.
|
system.screenshot(Storage type ) |
Storage type: 2: Storage.Usb 3: Storage.SdCard Returns: No return value |
Take a screenshot during runtime. The screenshot will be stored in Storage type .
|
system.setDateTime(Date date ) |
Date date: Date and time to set on the Xpanel Returns: No return value |
Sets the date and time on the Xpanel. This script will not work in the simulator.
|
system.setLanguage(String language ) |
String language: Language to be used by the String Table Editor Returns: No return value |
Sets the language to be used by the String Table Editor. This must match one of the columns in the String Table Editor.
|
system.staticBeep(boolean enable ) |
boolean enable: 0: false1: true
Returns: No return value |
Plays a beeping sound from the built-in Xpanel buzzer. This script does not work in the simulator.
|
system.video.playFile(Storage type , String path ) |
Storage type: 1: Storage.Local 2: Storage.Usb 3: Storage.SdCard 4: Storage.Ftp 5: Storage.Project String path:
Video file path location
Returns: No return value |
Opens a video for playback from the specified path. This script will not work in the simulator. This will only work on the eXT2 series.
|
system.video.stop() |
Returns: No return value |
Stops the current video playback. This script will not work in the simulator. This will only work on the eXT2 series.
|
Tag
Function | Parameters and Return Value |
Description and Example |
---|---|---|
tag.read(String name ) |
String name: Name of the tag to read Returns: Data type of the tag |
Gets the current value of the specified tag.
|
tag.write(String name , Value value ) |
String name: Name of the tag to read Value value: Value to change the tag to Returns: No return value |
Sets the value of the specified tag.
|
tag.writeBatch(Array tagNames , Array tagValues ) |
Array tagNames: Array of tag names to write to Array tagValues: Array of tag values to write Returns: No return value |
Writes to multiple tags at once.
|
Thread
Function | Parameters and Return Value |
Description and Example |
---|---|---|
thread.msleep(int msecs ) |
int msecs: Time in milliseconds Returns: No return value |
Suspends the current thread for the specified time, in milliseconds, before resuming execution.
|
thread.sleep(int secs ) |
int secs: Time in seconds Returns: No return value |
Suspends the current thread for the specified time, in seconds, before resuming execution.
|
JavaScript Scripts
The following scripts are built-in to the JavaScript language.
Array
Function | Parameters and Return Value |
Description and Example |
---|---|---|
Array.isArray(value ) |
value: The value to be checked Returns: Boolean value |
Returns a boolean value, true (1) or false (0), if the parameter is an array. Official documentation here.
|
Date
Function | Parameters and Return Value |
Description and Example |
---|---|---|
Date.now() |
Returns: Number |
Returns a number representing the timestamp, in milliseconds, of the current time. Official documentation here.
|
Date.parse(dateString ) |
dateString: String in the date time String format YYYY-MM-DDTHH:mm:ss:sssZ
Returns: Number |
Returns a number representing the timestamp of the given date. If dateString is invalid, NaN (not a number) is returned.Official documentation here.
|
Date.UTC(year , monthIndex , day , hours , minutes , seconds , milliseconds ) |
year: Integer value representing the year ranging from 0 to 99 mapping to the years 1900 to 1999 monthIndex: Optional parameter Integer value representing the month ranging from 0 to 11 mapping to the years January to December (default 0) day: Optional parameter Integer value representing the day of the month ranging from 1 to 31 (default 1) hours: Optional parameter Integer value representing the hour of the day ranging from 0 to 23 (default 0) minutes: Optional parameter Integer value representing minutes ranging from 0 to 59 (default 0) seconds: Optional parameter Integer value representing seconds ranging from 0 to 59 (default 0) milliseconds: Optional parameter Integer value representing milliseconds ranging from 0 to 59 (default 0) Returns: Number |
Returns a number representing the timestamp of the given date. If the input parameter is invalid, NaN (not a number) is returned.Official documentation here.
|
Global Objects
Function | Parameters and Return Value |
Description and Example |
---|---|---|
decodeURI(encodedURI ) |
encodedURI: Complete, encoded Uniform Resource Identifier Returns: String |
Returns a string representing the unencoded version of the given encoded Uniform Resource Identifier (URI). Official documentation here.
|
decodeURIComponent(encodedURI ) |
encodedURI: An encoded component of a Uniform Resource Identifier Returns: String |
Decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent() and returns a string representation of the encoded URI component.Official documentation here.
|
encodeURI(uri ) |
uri: String to be encoded as a URI Returns: String |
Returns a new String representing the provided String encoded as a URI. Official documentation here.
|
encodeURIComponent(uriComponent ) |
uriComponent: String to be encoded as a URI component Returns: String |
Returns a new String representing the provided String encoded as a URI component. Official documentation here.
|
escape(str )Deprecated |
str: String to be encoded Returns: String |
Returns a new String in which certain characters have been escaped. Official documentation here.
|
eval(script ) |
script: String representing a JavaScript expression, statement, or sequence of statements The expression can include variables and properties of existing objects Returns: Completion value of evaluating the given code |
Evaluates JavaScript code represented as a String and returns its completion value. The source is parsed as a script. Warning: Executing JavaScript from a string is an enormous security risk. It is far too easy for a bad actor to run arbitrary code when you use eval() .Official documentation here.
|
isFinite(value ) |
value: Value to be tested Returns: Boolean value |
Returns a boolean value, true (1) or false (0), if the specified value is not NaN , Infinity , or -Infinity .Official documentation here.
|
isNaN(value ) |
value: Value to be tested Returns: Boolean value |
Returns a boolean value, true (1) or false (0), if the specified value is NaN (not a number).Official documentation here.
|
parseFloat(string ) |
string: The value to parse, coerced to a String. Leading whitespace in this argument is ignored. Returns: Float value |
Returns a floating point number parsed from the given string or NaN (not a number) when the first non-whitespace character cannot be converted to a number.Official documentation here.
|
parseInt(string )parseInt( string , radix ) |
string: String starting with an Integer Leading whitespace in this argument is ignored. radix: Optional parameter Integer between 2 and 36 Returns: Integer value |
Returns the integer parsed from the given string .NaN (not a number) is returned when the radix is 2 > 32-bit integer radix or 36 < 32-bit integer radix , or the first non-whitespace character cannot be converted to a number.Official documentation here.
|
unescape(str )Deprecated |
str: String to be decoded Returns: String |
Returns a new String in which certain characters have been unescaped. Official documentation here.
|
JSON
Function | Parameters and Return Value |
Description and Example |
---|---|---|
JSON.parse(text )JSON.parse( text , reviver ) |
text: String to parse as JSON reviver: Optional parameter If a function, this prescribes how each value originally produced by parsing is transformed before being returned.
Returns: Object, Array, String, number, Boolean, or null value |
Parses a JSON string, constructing the JavaScript value or object described by the String. Official documentation here.
|
JSON.stringify(value )JSON.stringify( value , replacer )JSON.stringify( value , replacer , space ) |
value: The value to convert to a JSON String reviver: Optional parameter Function that alters the behavior of the stringification process, or an array of Strings and numbers that specifies properties of value to be included in the output
space: Optional parameter String or number that's used to insert white space (including indentation, line break, etc.) into the JSON String for readability purposes Returns: JSON String |
Converts a JavaScript value to a JSON String, optionally replacing values if a replacer function is specified or optionally including only the specified properties if a replacer array is specified. An optional reviver function can be provided to perform a transformation on the resulting object before it is returned.Official documentation here.
|
Math
Function | Parameters and Return Value |
Description and Example |
---|---|---|
Math.abs(x ) |
x: A number Returns: Number |
Returns the absolute value of x .If x is negative or -0, it returns its opposite number: -x (non-negative).The result is always positive or 0. Official documentation here.
|
Math.acos(x ) |
x: A number between -1 and 1 (inclusive) representing the angle's cosine value Returns: Number |
Returns the inverse cosine (angle in radians between 0 and π, inclusive) of x .If x is less than -1 or greater than 1, it returns NaN (not a number).Official documentation here.
|
Math.asin(x ) |
x: A number between -1 and 1 (inclusive) representing the angle's sine value Returns: Number |
Returns the inverse sine (angle in radians between -π/2 and π/2, inclusive) of x .If x is less than -1 or greater than 1, it returns NaN (not a number).Official documentation here.
|
Math.atan(x ) |
x: A number Returns: Number |
Returns the inverse tangent (angle in radians between -π/2 and π/2, inclusive) of x .If x is Infinity, it returns π/2.If x is -Infinity, it returns -π/2.Official documentation here.
|
Math.atan2(y , x ) |
y: Y coordinate of the point x: x coordinate of the point Returns: Number |
Returns the angle in the plane (angle in radians between -π and π, inclusive) between the positive x-axis and the ray from (0, 0) to the point (x , y ).Official documentation here.
|
Math.ceil(x ) |
x: A number Returns: Number |
Returns the smallest integer greater than or equal to x .This is the same value as -Math.floor(-x) .Official documentation here.
|
Math.cos(x ) |
x: A number representing an angle in radians Returns: Number |
Returns the cosine (angle in radians between 0 and π, inclusive) of x .If x is Infinity, -Infinity, or NaN, it returns NaN (not a number).Official documentation here.
|
Math.exp(x ) |
x: A number Returns: Number |
Returns a non-negative number representing ex , where e is the base of the natural logarithm.If x is Infinity, -Infinity, or NaN, it returns NaN (not a number).Official documentation here.
|
Math.floor(x ) |
x: A number Returns: Number |
Returns the largest integer less than or equal to x. This is the same value as -Math.ceil(-x) .Official documentation here.
|
Math.log(x ) |
x: A number greater than or equal to 0 Returns: Number |
Returns the natural logarithm (base e ) of x .If x is ±0, it returns -Infinity.If x is less than 0, it returns NaN.Official documentation here.
|
Math.max() Math.max( value1 )Math.max( value1 , value2 )Math.max( value1 , value2 , ... , valueN ) |
value: Optional parameters Zero or more numbers among which the largest value will be selected and returned Returns: Number |
Returns the largest of the given numbers. Returns NaN if any of the parameters is or is converted into NaN (not a number).Returns -Infinity if no parameters are provided. Official documentation here.
|
Math.min() Math.min( value1 )Math.min( value1 , value2 )Math.min( value1 , value2 , ... , valueN ) |
value: Optional parameters Zero or more numbers among which the smallest value will be selected and returned Returns: Number |
Returns the smallest of the given numbers. Returns NaN if any of the parameters is or is converted into NaN (not a number).Returns Infinity if no parameters are provided. Official documentation here.
|
Math.pow(base , exponent ) |
base: The base number exponent: The exponent number Returns: Number |
Returns a number representing base taken to the power of exponent .Returns NaN (not a number) in the following cases:
Official documentation here.
|
Math.random() |
Returns: Floating-point, pseudo-random number |
Returns a floating-point, pseudo-random number between 0 (inclusive) and 1 (exclusive). Official documentation here.
|
Math.round(x ) |
Returns: A number Returns: Number |
Returns the value of x rounded to the nearest integer.Official documentation here.
|
Math.sin(x ) |
x: A number representing an angle in radians Returns: Number |
Returns the sine (angle in radians between -1 and 1, inclusive) of x .If x is Infinity, -Infinity, or NaN, it returns NaN (not a number).Official documentation here.
|
Math.sqrt(x ) |
x: A number greater than or equal to 0 Returns: Number |
Returns the square root of x , a non-negative number.If x < 0 , it returns NaN (not a number).Official documentation here.
|
Math.tan(x ) |
x: A number representing an angle in radians Returns: Number |
Returns the tangent of x .If x is Infinity, -Infinity, or NaN, it returns NaN (not a number).Official documentation here.
|
Object
Function | Parameters and Return Value |
Description and Example |
---|---|---|
Object.create(proto )Object.create( proto , propertiesObject ) |
proto: The object which should be the prototype of the newly-created object propertiesObject: Optional parameter If specified and not undefined, an objet whose enumerable own properties specify property descriptors to be added to the newly-created object, with the corresponding property names. Returns: Object |
Creates a new object using an existing object as the prototype of the newly created object. Official documentation here.
|
Object.defineProperties(obj , props ) |
obj: The object on which to define or modify properties props: Object whose keys represent the names of properties to be defined or modified and whose values are objects describing those properties
Returns: Object |
Defines new or modifies existing properties directly on an object, returning the object. Official documentation here.
|
Object.defineProperty(obj , prop , descriptor ) |
obj: The object on which to define or modify properties prop: String or Symbol specifying the key of the property to be defined or modified descriptor: The descriptor for the property being defined or modified Returns: Object |
Defines a new property directly on an object, or modifies an existing property on an object, and returns the object. Official documentation here.
|
Object. getOwnPropertyDescriptor( obj , prop ) |
obj: The object in which to look for the property prop: Name or Symbol of the property whose description is to be retrieved Returns: Object |
Returns an object describing the configuration of a specific property on a given object. Official documentation here.
|
Object.getPrototypeOf(obj ) |
obj: The object whose prototype is to be returned Returns: Prototype |
Returns the prototype of the specified object or null. Official documentation here.
|
Object.keys(obj ) |
obj: An object Returns: Array |
Returns an array of a given object's own enumerable string-keyed property names. Official documentation here.
|
Object.preventExtensions(obj ) |
obj: The object which should be made non-extensible Returns: Object |
Prevents new properties from ever being added to an object. It also prevents the object's prototype from being reassigned. Official documentation here.
|
String
Function | Parameters and Return Value |
Description and Example |
---|---|---|
String.fromCharCode() String.fromCharCode( num1 )String.fromCharCode( num1 , num2 )String.fromCharCode( num1 , num2 , ... , numN ) |
num: Optional parameters Number between 0 and 65,535 (0xFFFF) representing a UTF-16 code unit Numbers greater than 0xFFFF are truncated to the last 16 bits Returns: String |
Returns a String created from the specified sequence of UTF-16 code units. Official documentation here.
|