throw-basic.js 280 B

123456789101112131415161718192021222324
  1. try {
  2. throw 1;
  3. } catch (e) {
  4. assert(e === 1);
  5. }
  6. try {
  7. throw [99];
  8. } catch (e) {
  9. assert(typeof e === "object");
  10. assert(e.length === 1);
  11. }
  12. function foo() {
  13. throw "hello";
  14. }
  15. try {
  16. foo();
  17. } catch (e) {
  18. assert(e === "hello");
  19. }
  20. console.log("PASS");