nativescript Global Variables Console


Example

NativeScript’s global console variable lets you print values to your terminal for debugging. The simplest usage is passing a value to the console.log() function:

console.log("hello world");

The console object has several other methods, including dump(), trace(), assert() and more.

// Prints the state of a full object.
console.dump({ firstName: "Native", lastName: "Script"}); 

// Prints the current stack trace
console.trace();

// Asserts a boolean condition, and prints to the console if the assertion fails.
console.assert(1 === 1, "This won’t print as the condition is true");
console.assert(1 === 2, "This will print as the condition is false");