GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

No menu could be recovered. Follow the blue links in the page.

This view

  • Original page
  • New address

GeezerVison is showing uz.javascript.info — SyntaxError dan meros olish

  • Qo'llanma
  • JavaScript dasturlash tili
  • Xatolarni qayta ishlash
  • Maxsus xatolar, Error kengaytmasi
darsga qaytish

muhimlik: 5


SyntaxError dan meros olish

O’rnatilgan SyntaxError klassidan meros oladigan FormatError klassini yarating.

U message, name va stack xususiyatlarini qo’llab-quvvatlashi kerak.

Foydalanish misoli:

let err = new FormatError("formatlash xatosi");

alert(err.message); // formatlash xatosi
alert(err.name); // FormatError
alert(err.stack); // stack

alert(err instanceof FormatError); // true
alert(err instanceof SyntaxError); // true (SyntaxError dan meros olganligi uchun)

Yechim

class FormatError extends SyntaxError {
  constructor(message) {
    super(message);
    this.name = "FormatError";
  }
}

// Test
let err = new FormatError("formatlash xatosi");

alert(err.message); // formatlash xatosi
alert(err.name); // FormatError
alert(err.stack); // stack (brauzerga bog'liq)

alert(err instanceof FormatError); // true
alert(err instanceof SyntaxError); // true
alert(err instanceof Error); // true
class FormatError extends SyntaxError {
  constructor(message) {
    super(message);
    this.name = this.constructor.name;
  }
}

let err = new FormatError("formatlashda xatolik");

alert(err.message); // formatlashda xatolik
alert(err.name); // FormatError
alert(err.stack); // stack

alert(err instanceof SyntaxError); // true
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.