【JavaScript】throw

用法

可以讓console panel噴出錯誤訊息

function count(number){
 if(number<10){
  throw 'number < 10';
 }else {
  throw 'number >= 10';
 }
}

噴出檔案名、行數

function count(number){
 if(number<10){
  throw new Error('number < 10');
 }else {
  throw 'number >= 10';
 }
}