nativescript
Globale variabelen
Zoeken…
Troosten
Met de globale console NativeScript kunt u waarden naar uw terminal afdrukken voor foutopsporing. Het eenvoudigste gebruik is een waarde doorgeven aan de functie console.log() :
console.log("hello world");
Het console object heeft verschillende andere methoden, waaronder dump() , trace() , assert() en meer .
// 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)
Global NativeScript's timer variabele kunt u time-outs en intervallen voor asynchrone vertraagde functie gesprekken in te stellen.
Importeren
var timer = require("timer")
Time-outs
var callback = function(){
console.log("I will be executed once after 500ms");
}
var timeoutId = timer.setTimeout(callback, 500);
// clearing the timeout
timer.clearTimeout(timeoutId);
intervallen
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
Licentie onder CC BY-SA 3.0
Niet aangesloten bij Stack Overflow