scala.scalajs

js

package js

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 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:

The 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 definitions 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 of None.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. js
  2. GlobalScope
  3. Object
  4. Any
  5. AnyRef
  6. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. sealed trait Any extends AnyRef

    Super-type of all JavaScript values.

  2. class Array[A] extends Object

    Arrays are list-like objects whose prototype has methods to perform traversal and mutation operations.

  3. final class ArrayOps[A] extends ArrayLike[A, Array[A]] with Builder[A, Array[A]]

    Equivalent of scm.

  4. type Boolean = scala.Boolean

    The type of JavaScript booleans, which is scala.Boolean.

  5. class Date extends Object

    Creates a JavaScript Date instance that represents a single moment in time.

  6. sealed trait Dictionary[A] extends Object

    Dictionary "view" of a JavaScript value.

  7. sealed trait Dynamic extends Any with scala.Dynamic

    Dynamically typed JavaScript value.

  8. class Error extends Object

    Annotations
    @RawJSType()
  9. class EvalError extends Error

    An instance representing an error that occurs regarding the global function eval()

  10. class Function extends Object

    The Function constructor creates a new Function object.

  11. trait Function0[+R] extends Function

    Annotations
    @RawJSType()
  12. trait Function1[-T1, +R] extends Function

    Annotations
    @RawJSType()
  13. trait Function10[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, +R] extends Function

    Annotations
    @RawJSType()
  14. trait Function11[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, +R] extends Function

    Annotations
    @RawJSType()
  15. trait Function12[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, +R] extends Function

    Annotations
    @RawJSType()
  16. trait Function13[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, +R] extends Function

    Annotations
    @RawJSType()
  17. trait Function14[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, +R] extends Function

    Annotations
    @RawJSType()
  18. trait Function15[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, +R] extends Function

    Annotations
    @RawJSType()
  19. trait Function16[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, +R] extends Function

    Annotations
    @RawJSType()
  20. trait Function17[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, +R] extends Function

    Annotations
    @RawJSType()
  21. trait Function18[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, -T18, +R] extends Function

    Annotations
    @RawJSType()
  22. trait Function19[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, -T18, -T19, +R] extends Function

    Annotations
    @RawJSType()
  23. trait Function2[-T1, -T2, +R] extends Function

    Annotations
    @RawJSType()
  24. trait Function20[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, -T18, -T19, -T20, +R] extends Function

    Annotations
    @RawJSType()
  25. trait Function21[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, -T18, -T19, -T20, -T21, +R] extends Function

    Annotations
    @RawJSType()
  26. trait Function22[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, -T18, -T19, -T20, -T21, -T22, +R] extends Function

    Annotations
    @RawJSType()
  27. trait Function3[-T1, -T2, -T3, +R] extends Function

    Annotations
    @RawJSType()
  28. trait Function4[-T1, -T2, -T3, -T4, +R] extends Function

    Annotations
    @RawJSType()
  29. trait Function5[-T1, -T2, -T3, -T4, -T5, +R] extends Function

    Annotations
    @RawJSType()
  30. trait Function6[-T1, -T2, -T3, -T4, -T5, -T6, +R] extends Function

    Annotations
    @RawJSType()
  31. trait Function7[-T1, -T2, -T3, -T4, -T5, -T6, -T7, +R] extends Function

    Annotations
    @RawJSType()
  32. trait Function8[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, +R] extends Function

    Annotations
    @RawJSType()
  33. trait Function9[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, +R] extends Function

    Annotations
    @RawJSType()
  34. trait GlobalScope extends Object

    Marker trait for top-level objects representing the JS global scope.

  35. trait JSApp extends AnyRef

    Base class for top-level, entry point main objects.

  36. trait JSArrayOps[A] extends Object

    Discouraged native JavaScript Array methods.

  37. case class JavaScriptException(exception: scala.Any) extends RuntimeException with Product with Serializable

  38. trait LowPrioAnyImplicits extends AnyRef

  39. type Number = Double

    The type of JavaScript numbers, which is scala.Double.

  40. class Object extends Any

    Base class of all JavaScript objects.

  41. trait PropertyDescriptor extends Object

    Annotations
    @RawJSType()
  42. class RangeError extends Error

    An instance representing an error that occurs when a numeric variable or parameter is outside of its valid range.

  43. class ReferenceError extends Error

    Represents an error when a non-existent variable is referenced.

  44. class RegExp extends Object

    The RegExp constructor creates a regular expression object for matching text with a pattern.

  45. type String = java.lang.String

    The type of JavaScript strings, which is java.lang.String.

  46. class SyntaxError extends Error

    Represents an error when trying to interpret syntactically invalid code.

  47. trait ThisFunction extends Function

    A JavaScript function where this is considered as a first parameter.

  48. trait ThisFunction0[-T0, +R] extends Function with ThisFunction

    Annotations
    @RawJSType()
  49. trait ThisFunction1[-T0, -T1, +R] extends Function with ThisFunction

    Annotations
    @RawJSType()
  50. trait ThisFunction10[-T0, -T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, +R] extends Function with ThisFunction

    Annotations
    @RawJSType()
  51. trait ThisFunction11[-T0, -T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, +R] extends Function with ThisFunction

    Annotations
    @RawJSType()
  52. trait ThisFunction12[-T0, -T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, +R] extends Function with ThisFunction

    Annotations
    @RawJSType()
  53. trait ThisFunction13[-T0, -T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, +R] extends Function with ThisFunction

    Annotations
    @RawJSType()
  54. trait ThisFunction14[-T0, -T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, +R] extends Function with ThisFunction

    Annotations
    @RawJSType()
  55. trait ThisFunction15[-T0, -T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, +R] extends Function with ThisFunction

    Annotations
    @RawJSType()
  56. trait ThisFunction16[-T0, -T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, +R] extends Function with ThisFunction

    Annotations
    @RawJSType()
  57. trait ThisFunction17[-T0, -T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, +R] extends Function with ThisFunction

    Annotations
    @RawJSType()
  58. trait ThisFunction18[-T0, -T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, -T18, +R] extends Function with ThisFunction

    Annotations
    @RawJSType()
  59. trait ThisFunction19[-T0, -T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, -T18, -T19, +R] extends Function with ThisFunction

    Annotations
    @RawJSType()
  60. trait ThisFunction2[-T0, -T1, -T2, +R] extends Function with ThisFunction

    Annotations
    @RawJSType()
  61. trait ThisFunction20[-T0, -T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, -T18, -T19, -T20, +R] extends Function with ThisFunction

    Annotations
    @RawJSType()
  62. trait ThisFunction21[-T0, -T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, -T18, -T19, -T20, -T21, +R] extends Function with ThisFunction

    Annotations
    @RawJSType()
  63. trait ThisFunction3[-T0, -T1, -T2, -T3, +R] extends Function with ThisFunction

    Annotations
    @RawJSType()
  64. trait ThisFunction4[-T0, -T1, -T2, -T3, -T4, +R] extends Function with ThisFunction

    Annotations
    @RawJSType()
  65. trait ThisFunction5[-T0, -T1, -T2, -T3, -T4, -T5, +R] extends Function with ThisFunction

    Annotations
    @RawJSType()
  66. trait ThisFunction6[-T0, -T1, -T2, -T3, -T4, -T5, -T6, +R] extends Function with ThisFunction

    Annotations
    @RawJSType()
  67. trait ThisFunction7[-T0, -T1, -T2, -T3, -T4, -T5, -T6, -T7, +R] extends Function with ThisFunction

    Annotations
    @RawJSType()
  68. trait ThisFunction8[-T0, -T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, +R] extends Function with ThisFunction

    Annotations
    @RawJSType()
  69. trait ThisFunction9[-T0, -T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, +R] extends Function with ThisFunction

    Annotations
    @RawJSType()
  70. class TypeError extends Error

    Represents an error when a value is not of the expected type.

  71. class URIError extends Error

    Represents an error when a malformed URI is encountered.

  72. sealed trait UndefOr[+A] extends AnyRef

    Value of type A or the JS undefined value.

  73. final class UndefOrOps[A] extends AnyVal

  74. type Undefined = Unit

    The type of the JavaScript undefined value, which is scala.Unit.

  75. final class WrappedArray[A] extends AbstractBuffer[A] with GenericTraversableTemplate[A, WrappedArray] with collection.mutable.IndexedSeq[A] with BufferLike[A, WrappedArray[A]] with ArrayLike[A, WrappedArray[A]] with Builder[A, WrappedArray[A]]

    Equivalent of scm.

  76. class WrappedDictionary[A] extends AbstractMap[String, A] with Map[String, A] with MapLike[String, A, WrappedDictionary[A]]

    Wrapper to use a js.

Value Members

  1. object Any extends LowPrioAnyImplicits

    Provides implicit conversions from Scala values to JavaScript values.

  2. object Array extends Object

    Factory for js.Array objects.

  3. object ArrayOps

  4. val Boolean: js.prim.Boolean.type

    The top-level Boolean JavaScript object.

  5. object Date extends Object

    Factory for js.Date objects.

  6. object Dictionary

    Factory for Dictionary instances.

  7. object Dynamic

    Factory for dynamically typed JavaScript values.

  8. object Error extends Object

  9. object EvalError extends Object

  10. object Function extends Object

  11. val Infinity: Double

    The constant Positive Infinity.

  12. object JSArrayOps

  13. object JSConverters

    A collection of decorators that allow converting Scala types to corresponding JS facade types

  14. object JSON extends Object

    The JSON object contains methods for converting values to JavaScript Object Notation (JSON) and for converting JSON to values.

  15. object Math extends Object

    Math is a built-in object that has properties and methods for mathematical constants and functions.

  16. val NaN: Double

    The constant Not-a-Number.

  17. val Number: js.prim.Number.type

    The top-level Number JavaScript object.

  18. object Object extends Object

    The top-level Object JavaScript object.

  19. object RangeError extends Object

  20. object ReferenceError extends Object

  21. object RegExp extends Object

  22. val String: js.prim.String.type

    The top-level String JavaScript object.

  23. object SyntaxError extends Object

  24. object ThisFunction

  25. object TypeError extends Object

  26. object URIError extends Object

  27. object UndefOr

  28. object UndefOrOps

  29. object WrappedArray extends SeqFactory[WrappedArray]

    $factoryInfo

  30. object WrappedDictionary

  31. package annotation

  32. def debugger(): Unit

    Invokes any available debugging functionality.

    Invokes any available debugging functionality. If no debugging functionality is available, this statement has no effect.

    MDN

    Browser support:

    • Has no effect in Rhino nor, apparently, in Firefox
    • In Chrome, it has no effect unless the developer tools are opened beforehand.
  33. def decodeURI(encodedURI: String): String

    Decodes a Uniform Resource Identifier (URI).

    Decodes a Uniform Resource Identifier (URI).

    See also

    encodeURI

  34. def decodeURIComponent(encodedURIComponent: String): String

    Decodes a Uniform Resource Identifier (URI) component.

    Decodes a Uniform Resource Identifier (URI) component.

    See also

    encodeURIComponent

  35. def encodeURI(uri: String): String

    Encodes a Uniform Resource Identifier (URI).

    Encodes a Uniform Resource Identifier (URI).

    See also

    decodeURI

  36. def encodeURIComponent(uriComponent: String): String

    Encodes a Uniform Resource Identifier (URI) component.

    Encodes a Uniform Resource Identifier (URI) component.

    See also

    decodeURIComponent

  37. def eval(x: String): Any

    Evaluates JavaScript code and returns the result.

  38. def hasOwnProperty(v: String): Boolean

    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

    Definition Classes
    Object
  39. def isFinite(number: Double): Boolean

    Tests whether the given value is a finite number.

  40. def isNaN(number: Double): Boolean

    Tests whether the given value is Not-a-Number.

  41. def isPrototypeOf(v: Object): Boolean

    Tests whether this object is in the prototype chain of another object.

    Tests whether this object is in the prototype chain of another object.

    Definition Classes
    Object
  42. def isUndefined(v: scala.Any): Boolean

    Tests whether the given value is undefined.

  43. def native: Nothing

    Denotes a method body as native JavaScript.

    Denotes a method body as native JavaScript. For use in facade types:

    class MyJSClass extends js.Object {
    def myMethod(x: String): Int = js.native
    }
  44. def parseFloat(string: String): Double

    Parses a string as a floating point number.

  45. def parseInt(s: String): Number

    Parses a string as an integer with auto-detected radix.

  46. def parseInt(s: String, radix: Int): Number

    Parses a string as an integer with a given radix.

  47. package prim

  48. def propertyIsEnumerable(v: String): Boolean

    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

    Definition Classes
    Object
  49. def toLocaleString(): String

    Definition Classes
    Object
  50. def typeOf(x: Any): String

    Returns the type of x as identified by typeof x in JavaScript.

  51. package typedarray

    The typdearray package provides facade types for JavaScript ArrayBuffer, TypeArrays and DataView.

  52. def undefined: js.prim.Undefined

    The undefined value.

  53. def valueOf(): scala.Any

    Definition Classes
    Object

Inherited from GlobalScope

Inherited from Object

Inherited from Any

Inherited from AnyRef

Inherited from scala.Any

Ungrouped