nativescript
전역 변수
수색…
콘솔
NativeScript의 전역 console 변수를 사용하면 디버깅을 위해 터미널에 값을 인쇄 할 수 있습니다. 가장 간단한 사용법은 console.log() 함수에 값을 전달하는 것입니다.
console.log("hello world");
console 객체에는 dump() , trace() , assert() 등을 비롯한 몇 가지 다른 메소드가 있습니다 .
// 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");
타이머 (JavaScript)
NativeScript의 전역 timer 변수를 사용하면 비동기 지연된 함수 호출에 대한 시간 초과 및 간격을 설정할 수 있습니다.
가져 오는 중
var timer = require("timer")
시간 초과
var callback = function(){
console.log("I will be executed once after 500ms");
}
var timeoutId = timer.setTimeout(callback, 500);
// clearing the timeout
timer.clearTimeout(timeoutId);
간격
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
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow