控制檯

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");