nativescript
Globala variabler
Sök…
Trösta
Med NativeScript globala console kan du skriva ut värden till din terminal för felsökning. Den enklaste användningen överför ett värde till funktionen console.log() :
console.log("hello world");
console har flera andra metoder, inklusive dump() , trace() , assert() och mer .
// 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");
Timer (JavaScript)
NativeScript globala timer låter dig ställa in tidsgränser och intervaller för asynkrona försenade funktionssamtal.
importera
var timer = require("timer")
Tidsgränser
var callback = function(){
console.log("I will be executed once after 500ms");
}
var timeoutId = timer.setTimeout(callback, 500);
// clearing the timeout
timer.clearTimeout(timeoutId);
intervaller
var callback = function(){
console.log("I will be executed every 500 ms")
}
var intervalId = timer.setInterval(callback, 500);
// clearing the interval
timer.clearInterval(intervalId);
Modified text is an extract of the original Stack Overflow Documentation
Licensierat under CC BY-SA 3.0
Inte anslutet till Stack Overflow