Super-type of all JavaScript values.
Super-type of all JavaScript values.
All values of a subtype of this trait represent JavaScript values, without boxing of proxying of any kind.
Arrays are list-like objects whose prototype has methods to perform traversal and mutation operations.
Arrays are list-like objects whose prototype has methods to perform traversal and mutation operations. Neither the length of a JavaScript array nor the types of its elements are fixed. Since an array's size length grow or shrink at any time, JavaScript arrays are not guaranteed to be dense. In general, these are convenient characteristics; but if these features are not desirable for your particular use, you might consider using typed arrays.
MDN
To construct a new array with uninitialized elements, use the constructor of this class. To construct a new array with specified elements, as if you used the array literal syntax in JavaScript, use the Array.apply method instead.
Type of the elements of the array
Equivalent of scm.ArrayOps for js.Array
The type of JavaScript booleans, which is scala.Boolean.
Creates a JavaScript Date instance that represents a single moment in time.
Creates a JavaScript Date instance that represents a single moment in time. Date objects are based on a time value that is the number of milliseconds since 1 January, 1970 UTC.
MDN
Dictionary "view" of a JavaScript value.
Dictionary "view" of a JavaScript value.
Using objects as dictionaries (maps from strings to values) through their properties is a common idiom in JavaScript. This trait lets you treat an object as such a dictionary.
To use it, cast your object, say x
, into a Dictionary using
val xDict = x.asInstanceOf[js.Dictionary[Int]]
then use it as
xDict("prop") = 5 println(xDict("prop")) // displays 5 xDict.delete("prop") // removes the property "prop" println(xDict("prop")) // displays undefined
To enumerate all the keys of a dictionary, use js.Object.keys, which returns a js.Array of the properties. It can be used in a for comprehension like this:
for (prop <- js.Object.keys(xDict)) { val value = xDict(prop) println(prop + " -> " + value) }
Dynamically typed JavaScript value.
Dynamically typed JavaScript value.
Values of this trait accept all possible JavaScript operations in a dynamically typed way. You can read and write any field, call any method, apply any JavaScript operator to values of this type.
An instance representing an error that occurs regarding the global function eval()
An instance representing an error that occurs regarding the global function eval()
MDN
The Function constructor creates a new Function object.
The Function constructor creates a new Function object. In JavaScript every function is actually a Function object.
Function objects created with the Function constructor are parsed when the function is created. This is less efficient than declaring a function and calling it within your code, because functions declared with the function statement are parsed with the rest of the code.
All arguments passed to the function are treated as the names of the identifiers of the parameters in the function to be created, in the order in which they are passed.
Note: Functions created with the Function constructor do not create closures to their creation contexts; they always are created in the global scope. When running them, they will only be able to access their own local variables and global ones, not the ones from the scope in which the Function constructor was called. This is different from using eval with code for a function expression.
Invoking the Function constructor as a function (without using the new operator) has the same effect as invoking it as a constructor.
MDN
Marker trait for top-level objects representing the JS global scope.
Marker trait for top-level objects representing the JS global scope.
When calling method on a top-level object or package object that is a subtype of GlobalScope, the receiver is dropped, and the JavaScript global scope is used instead.
Base class for top-level, entry point main objects.
Base class for top-level, entry point main objects.
Objects inheriting from JSApp are automatically exported to JavaScript under their fully qualified name, and their main method as well.
JSApp is typically used to mark the entry point of a Scala.js
application. As such, the sbt plugin also recognizes top-level objects
extending JSApp. It allows to run their main method with sbt run
,
and can also generate a tiny JavaScript launcher snippet executing the
main method of one specific JSApp object.
The type of JavaScript numbers, which is scala.Double.
Base class of all JavaScript objects.
Base class of all JavaScript objects.
An instance representing an error that occurs when a numeric variable or parameter is outside of its valid range.
An instance representing an error that occurs when a numeric variable or parameter is outside of its valid range.
A RangeError is thrown when trying to pass a number as an argument to a function that does not allow a range that includes that number. This can be encountered when to create an array of an illegal length with the Array constructor, or when passing bad values to the numeric methods toExponential, toFixed, or toPrecision.
MDN
Represents an error when a non-existent variable is referenced.
Represents an error when a non-existent variable is referenced.
A ReferenceError is thrown when trying to dereference a variable that has not been declared.
MDN
The RegExp constructor creates a regular expression object for matching text with a pattern.
The RegExp constructor creates a regular expression object for matching text with a pattern.
MDN
The type of JavaScript strings, which is java.lang.String.
Represents an error when trying to interpret syntactically invalid code.
Represents an error when trying to interpret syntactically invalid code.
A SyntaxError is thrown when the JavaScript engine encounters tokens or token order that does not conform to the syntax of the language when parsing code.
MDN
A JavaScript function where this
is considered as a first parameter.
A JavaScript function where this
is considered as a first parameter.
Represents an error when a value is not of the expected type.
Represents an error when a value is not of the expected type.
A TypeError is thrown when an operand or argument passed to a function is incompatible with the type expected by that operator or function.
MDN
Represents an error when a malformed URI is encountered.
Represents an error when a malformed URI is encountered.
A URIError is thrown when the URI handling functions are passed a malformed URI.
MDN
Value of type A or the JS undefined value.
Value of type A or the JS undefined value.
In a type system with union types, this would really be
A | js.prim.Undefined
. Since Scala does not have union types, but this
particular union is crucial to many interoperability scenarios, it is
provided as this trait.
An API similar to that of scala.Option is provided through the
UndefOrOps implicit class, with the understanding that undefined
is
the None value.
The type of the JavaScript undefined value, which is scala.Unit.
Equivalent of scm.WrappedArray for js.Array
Wrapper to use a js.Dictionary as a scala.mutable.Map
Provides implicit conversions from Scala values to JavaScript values.
Factory for js.Array objects.
The top-level Boolean
JavaScript object.
Factory for js.Date objects.
Factory for Dictionary instances.
Factory for dynamically typed JavaScript values.
The constant Positive Infinity.
The JSON object contains methods for converting values to JavaScript Object Notation (JSON) and for converting JSON to values.
The JSON object contains methods for converting values to JavaScript Object Notation (JSON) and for converting JSON to values.
MDN
Math is a built-in object that has properties and methods for mathematical constants and functions.
Math is a built-in object that has properties and methods for mathematical constants and functions. Not a function object.
MDN
The constant Not-a-Number.
The top-level Number
JavaScript object.
The top-level Object
JavaScript object.
The top-level String
JavaScript object.
Invokes any available debugging functionality.
Invokes any available debugging functionality. If no debugging functionality is available, this statement has no effect.
MDN
Browser support:
Decodes a Uniform Resource Identifier (URI).
Decodes a Uniform Resource Identifier (URI).
Decodes a Uniform Resource Identifier (URI) component.
Decodes a Uniform Resource Identifier (URI) component.
Encodes a Uniform Resource Identifier (URI).
Encodes a Uniform Resource Identifier (URI).
Encodes a Uniform Resource Identifier (URI) component.
Encodes a Uniform Resource Identifier (URI) component.
Evaluates JavaScript code and returns the result.
Tests whether this object has the specified property as a direct property.
Tests whether this object has the specified property as a direct property.
Unlike js.Object.hasProperty, this method does not check down the object's prototype chain.
MDN
Tests whether the given value is a finite number.
Tests whether the given value is Not-a-Number.
Tests whether this object is in the prototype chain of another object.
Tests whether this object is in the prototype chain of another object.
Tests whether the given value is undefined.
Parses a string as a floating point number.
Parses a string as an integer with auto-detected radix.
Parses a string as an integer with a given radix.
Tests whether the specified property in an object can be enumerated by a call to js.Object.properties, with the exception of properties inherited through the prototype chain.
Tests whether the specified property in an object can be enumerated by a call to js.Object.properties, with the exception of properties inherited through the prototype chain. If the object does not have the specified property, this method returns false.
MDN
Returns the type of x
as identified by typeof x
in JavaScript.
The typdearray package provides facade types for JavaScript ArrayBuffer, TypeArrays and DataView.
The typdearray package provides facade types for JavaScript ArrayBuffer, TypeArrays and DataView. Further, it provides conversions between primitive Scala arrays and TypedArrays
The undefined value.
Contains primitive types for interoperability with JavaScript libraries. This package is only relevant to the Scala.js compiler, and should not be referenced by any project compiled to the JVM.
All the values and methods in this package object are representatives of standard variables and functions available in the top-level scope, as standardized in ECMAScript 5.1.
Guide
General documentation on Scala.js can is available at http://www.scala-js.org/doc/.
Overview
The trait js.Any is the super type of all JavaScript values.
All class, trait and object definitions that inherit, directly or indirectly, from js.Any do not have actual implementations in Scala. They are only the manifestation of static types representing libraries written directly in JavaScript. It is not possible to implement yourself a subclass of js.Any: all the method definitions will be ignored when compiling to JavaScript.
Implicit conversions to and from standard Scala types to their equivalent in JavaScript are provided. For example, from Scala arrays to JavaScript arrays and back.
The most important subclasses of js.Any are:
this
as an explicit parametersThe trait js.Dynamic is a special subtrait of js.Any. It can represent any JavaScript value in a dynamically typed way. It is possible to call any method and read and write any field of a value of type js.Dynamic.
The package scala.scalajs.js.prim gives definition for the four primitive types of JavaScript as subtraits of js.Any, but generally it is preferable to use the corresponding Scala type.
js.UndefOr gives a scala.Option-like interface where the JavaScript value
undefined
takes the role ofNone
.