scala.scalajs

js

package js

Types, methods and values 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.

Guide

General documentation on Scala.js is available at http://www.scala-js.org/doc/.

Overview

The trait js.Any is the root of the hierarchy of JavaScript types. This package defines important subtypes of js.Any that are defined in the standard library of ECMAScript 5.1 (or ES 6, with a label in the documentation), such as js.Object, js.Array and js.RegExp.

Implicit conversions to and from standard Scala types to their equivalent in JavaScript are provided. For example, from Scala functions to JavaScript functions and back.

The most important subtypes of js.Any declared in this package 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.

There are no explicit definitions for JavaScript primitive types, as one could expect, because the corresponding Scala types stand in their stead:

js.UndefOr gives a scala.Option-like interface where the JavaScript value undefined takes the role of None.

A | B is an unboxed pseudo-union type, suitable to type values that admit several unrelated types in facade types.

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

Type Members

  1. trait Any extends AnyRef

    Root of the hierarchy of JavaScript types.

  2. class Array[A] extends Object with Iterable[A]

    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.ArrayOps for js.Array.

  4. final class ConstructorTag[T <: Any] extends AnyVal

    Stores the JS constructor function of a JS class.

  5. class Date extends Object

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

  6. sealed trait Dictionary[A] extends Any

    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() @native() @JSGlobal()
  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() @native()
  12. trait Function1[-T1, +R] extends Function

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

    Annotations
    @RawJSType() @native()
  14. trait Iterable[+A] extends Object

    ECMAScript 6 JavaScript Iterable.

  15. final class IterableOps[+A] extends collection.Iterable[A]

    Adapts a JavaScript Iterable to a Scala Iterable

  16. trait Iterator[+A] extends Object

    ECMAScript 6 JavaScript Iterator.

  17. trait JSArrayOps[A] extends Object

    Discouraged native JavaScript Array methods.

  18. sealed abstract class JSConvertersLowPrioImplicits extends AnyRef

  19. trait JSNumberOps extends Any

    Operations on JavaScript numbers.

  20. trait JSStringOps extends Any

    Operations on JavaScript strings.

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

  22. sealed trait LowPrioAnyImplicits extends LowestPrioAnyImplicits

  23. sealed trait LowestPrioAnyImplicits extends AnyRef

  24. class Object extends Any

    Base class of all JavaScript objects.

  25. class Promise[+A] extends Object with Thenable[A]

    ECMAScript 6 Promise of an asynchronous result.

  26. trait PropertyDescriptor extends Object

    Annotations
    @RawJSType()
  27. class RangeError extends Error

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

  28. class ReferenceError extends Error

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

  29. class RegExp extends Object

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

  30. sealed trait Symbol extends Any

    ECMAScript 6 JavaScript Symbol.

  31. class SyntaxError extends Error

    Represents an error when trying to interpret syntactically invalid code.

  32. trait Thenable[+A] extends Object

    A thing on which one can call the then method.

  33. trait ThisFunction extends Function

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

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

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

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

    Annotations
    @RawJSType() @native()
  37. sealed trait Tuple2[+T1, +T2] extends Object

    A tuple "view" of 2 elements of a JavaScript js.Array.

  38. sealed trait Tuple3[+T1, +T2, +T3] extends Object

    A tuple "view" of 3 elements of a JavaScript js.Array.

  39. class TypeError extends Error

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

  40. class URIError extends Error

    Represents an error when a malformed URI is encountered.

  41. type UndefOr[+A] = |[A, Unit]

    Value of type A or the JS undefined value.

    Value of type A or the JS undefined value.

    This type is actually strictly equivalent to A | Unit, since Unit is the type of the undefined value.

    js.UndefOr[A] is the type of a value that can be either undefined or an A. It provides an API similar to that of scala.Option through the UndefOrOps implicit class, where undefined take the role of None.

    By extension, this type is also suited to typing optional fields in native JS types, i.e., fields that may not exist on the object.

  42. final class UndefOrOps[A] extends AnyVal

  43. sealed trait UnicodeNormalizationForm extends Any

    A Unicode Normalization Form.

  44. 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.WrappedArray for js.Array.

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

    Wrapper to use a js.

  46. class native extends Annotation with StaticAnnotation

    Marks the annotated class, trait or object as a native JS entity.

  47. sealed trait |[A, B] extends AnyRef

    Value of type A or B (union type).

Value Members

  1. object Any extends LowPrioAnyImplicits

    Provides implicit conversions from Scala values to JavaScript values.

  2. object Array

    Factory for js.Array objects.

  3. object ArrayOps

  4. object ConstructorTag

  5. object Date extends Object

    Factory for js.Date objects.

  6. object Dictionary

    Factory for js.Dictionary instances.

  7. object Dynamic

    Factory for dynamically typed JavaScript values.

  8. object DynamicImplicits

    Provides implicit conversions and operations to write in JavaScript style with js.Dynamic.

  9. object Error extends Object

    Annotations
    @native() @JSGlobal()
  10. object EvalError extends Object

    Annotations
    @native() @JSGlobal()
  11. object Function extends Object

    Annotations
    @native() @JSGlobal()
  12. object Iterator

  13. object JSArrayOps

  14. object JSConverters extends JSConvertersLowPrioImplicits

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

  15. object JSNumberOps

  16. object JSON extends Object

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

  17. object JSStringOps

  18. object Math extends Object

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

  19. object Object extends Object

    The top-level Object JavaScript object.

  20. object Promise extends Object

    Annotations
    @native() @JSGlobal()
  21. object RangeError extends Object

    Annotations
    @native() @JSGlobal()
  22. object ReferenceError extends Object

    Annotations
    @native() @JSGlobal()
  23. object RegExp extends Object

    Annotations
    @native() @JSGlobal()
  24. object Symbol extends Object

    ECMAScript 6 Factory for js.Symbols and well-known symbols.

  25. object SyntaxError extends Object

    Annotations
    @native() @JSGlobal()
  26. object Thenable

  27. object ThisFunction

  28. object Tuple2

  29. object Tuple3

  30. object TypeError extends Object

    Annotations
    @native() @JSGlobal()
  31. object URIError extends Object

    Annotations
    @native() @JSGlobal()
  32. object URIUtils extends Object

    Methods related to URIs, provided by ECMAScript 5.

  33. object UndefOrOps

  34. object UnicodeNormalizationForm

  35. object WrappedArray extends SeqFactory[WrappedArray]

    Factory for js.WrappedArray.

  36. object WrappedDictionary

  37. package annotation

  38. def constructorOf[T <: Any]: Dynamic

    Returns the constructor function of a JavaScript class.

    Returns the constructor function of a JavaScript class.

    The specified type parameter T must be a class type (i.e., valid for classOf[T]) and represent a class extending js.Any (not a trait nor an object).

  39. def constructorTag[T <: Any](implicit tag: ConstructorTag[T]): ConstructorTag[T]

    Makes explicit an implicitly available js.ConstructorTag.

  40. object defined

  41. def eval(x: String): scala.Any

    Evaluates JavaScript code and returns the result.

    Evaluates JavaScript code and returns the result.

    Annotations
    @inline()
  42. def isUndefined(v: scala.Any): Boolean

    Tests whether the given value is undefined.

    Tests whether the given value is undefined.

    Annotations
    @inline()
  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. package timers

    Non-Standard Non-standard, but in general well supported methods to schedule asynchronous execution.

  45. def typeOf(x: scala.Any): String

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

  46. package typedarray

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

  47. def undefined: UndefOr[Nothing]

    The undefined value.

    The undefined value.

    Annotations
    @inline()
  48. object |

Inherited from AnyRef

Inherited from scala.Any

Ungrouped