W3cubDocs

/Haxe JavaScript

Lib

package js

Available on js

Platform-specific JavaScript Library. Provides some platform-specific functions for the JavaScript target.

Static variables

staticread onlyglobal:Dynamic

An alias of the JS "global" object.

Concretely, it is set as the first defined value in the list of window, global, self, and this in the top-level of the compiled output.

staticread onlynativeThis:Dynamic

nativeThis is the JavaScript this, which is semantically different from the Haxe this. Use nativeThis only when working with external JavaScript code.

In Haxe, this is always bound to a class instance. In JavaScript, this in a function can be bound to an arbitrary variable when the function is called using func.call(thisObj, ...) or func.apply(thisObj, [...]).

Read more at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this

staticread onlyundefined:Dynamic

Returns JavaScript undefined value.

Note that this is only needed in very rare cases when working with external JavaScript code.

In Haxe, null is used to represent the absence of a value.

staticread onlyparseInt:(string:String, radix:Int) ‑> Float

Native JavaScript parseInt function.

Its specification is different from Std.parseInt, so one might want to access the native one.

Static methods

staticalert(v:Dynamic):Void

Deprecated: "Lib.alert() is deprecated, use Browser.alert() instead"
Deprecated: Use Browser.alert() instead.

Display an alert message box containing the given message.

staticinlinedebug():Void

Inserts a 'debugger' statement that will make a breakpoint if a debugger is available.

staticinlineeval(code:String):Dynamic

staticgetOriginalException():Dynamic

Get original caught exception object, before unwrapping the js.Boot.HaxeError.

Can be useful if we want to redirect the original error into some external API (e.g. Promise or node.js callbacks).

Calling this is only possible inside a catch statement.

staticinlinerequire(module:String):Dynamic

Inserts a require expression that loads JavaScript object from a module or file specified in the module argument.

This is only supported in environments where require function is available, such as Node.js or RequireJS.

staticrethrow():Void

Re-throw last cathed exception, preserving original stack information.

Calling this is only possible inside a catch statement.

staticinlinetypeof(o:Dynamic):String

Call JavaScript typeof operator on the o value and return a string representing the JavaScript type of a value.

Read more at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof

© 2005–2020 Haxe Foundation
Licensed under a MIT license.
https://api.haxe.org/js/Lib.html