我在代码中使用断言,这是示例:
this.getNewLinkId = function() {
var newLinkId = this.links.length + 1;
console.assert(this.getLink(newLinkId).length === 0, 'Generated ID is already present within links!');
return newLinkId;
};
但由于它们,代码可能稍微难以阅读。有没有办法为assert
函数指定语法高亮?例如,使他们的颜色像评论那样?
答案 0 :(得分:0)
据我所知,你不能在NB那样做。也许战略换行可能对你有帮助吗?
e.g。
this.getNewLinkId = function() {
var newLinkId = this.links.length + 1;
console.assert(this.getLink(newLinkId).length === 0,
'Generated ID is already present within links!');
return newLinkId;
};