aboutsummaryrefslogtreecommitdiff
path: root/files/bg/web/javascript/reference/errors
diff options
context:
space:
mode:
Diffstat (limited to 'files/bg/web/javascript/reference/errors')
-rw-r--r--files/bg/web/javascript/reference/errors/index.html31
-rw-r--r--files/bg/web/javascript/reference/errors/unexpected_type/index.html70
2 files changed, 101 insertions, 0 deletions
diff --git a/files/bg/web/javascript/reference/errors/index.html b/files/bg/web/javascript/reference/errors/index.html
new file mode 100644
index 0000000000..c295fccea6
--- /dev/null
+++ b/files/bg/web/javascript/reference/errors/index.html
@@ -0,0 +1,31 @@
+---
+title: JavaScript error reference
+slug: Web/JavaScript/Reference/Errors
+tags:
+ - Debugging
+ - Error
+ - Errors
+ - Exception
+ - JavaScript
+ - NeedsTranslation
+ - TopicStub
+ - exceptions
+translation_of: Web/JavaScript/Reference/Errors
+---
+<p>{{jsSidebar("Errors")}}</p>
+
+<p>Below, you'll find a list of errors which are thrown by JavaScript. These errors can be a helpful debugging aid, but the reported problem isn't always immediately clear. The pages below will provide additional details about these errors. Each error is an object based upon the {{jsxref("Error")}} object, and has a <code>name</code> and a <code>message</code>.</p>
+
+<p>Errors displayed in the Web console may include a link to the corresponding page below to help you quickly comprehend the problem in your code.</p>
+
+<h2 id="List_of_errors">List of errors</h2>
+
+<p>In this list, each page is listed by name (the type of error) and message (a more detailed human-readable error message). Together, these two properties provide a starting point toward understanding and resolving the error. For more information, follow the links below!</p>
+
+<p>{{ListSubPages("/en-US/docs/Web/JavaScript/Reference/Errors")}}</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Learn/JavaScript/First_steps/What_went_wrong">What went wrong? Troubleshooting JavaScript</a>: Beginner's introductory tutorial on fixing JavaScript errors.</li>
+</ul>
diff --git a/files/bg/web/javascript/reference/errors/unexpected_type/index.html b/files/bg/web/javascript/reference/errors/unexpected_type/index.html
new file mode 100644
index 0000000000..372560f00e
--- /dev/null
+++ b/files/bg/web/javascript/reference/errors/unexpected_type/index.html
@@ -0,0 +1,70 @@
+---
+title: 'TypeError: "x" is (not) "y"'
+slug: Web/JavaScript/Reference/Errors/Unexpected_type
+tags:
+ - JavaScript
+ - TypeError
+ - Грешки
+translation_of: Web/JavaScript/Reference/Errors/Unexpected_type
+---
+<div>{{jsSidebar("Errors")}}</div>
+
+<h2 id="Съобщение">Съобщение</h2>
+
+<pre class="syntaxbox">TypeError: "x" is (not) "y"
+
+Примери:
+TypeError: "x" is undefined
+TypeError: "x" is null
+TypeError: "undefined" is not an object
+TypeError: "x" is not an object or null
+TypeError: "x" is not a symbol
+</pre>
+
+<h2 id="Вид_на_грешката">Вид на грешката</h2>
+
+<p>{{jsxref("TypeError")}}.</p>
+
+<h2 id="Какво_се_обърка"><span class="short_text" id="result_box" lang="bg"><span>Какво се обърка?</span></span></h2>
+
+<p>Върнатият тип не отговаря на очакванията. Това се случва често при върната стойност {{jsxref("undefined")}} или {{jsxref("null")}}.</p>
+
+<p>Някои методи като {{jsxref("Object.create()")}} или {{jsxref("Symbol.keyFor()")}} освен това изискват да им бъде предоставен определен тип.</p>
+
+<h2 id="Примери">Примери</h2>
+
+<h3 id="Случаи_предизвикващи_грешката">Случаи, предизвикващи грешката</h3>
+
+<pre class="brush: js example-bad">// Случаи, при които методът substring няма да работи.
+// Такива са undefined и null.
+var foo = undefined;
+foo.substring(1); // TypeError: foo is undefined
+
+var foo = null;
+foo.substring(1); // TypeError: foo is null
+
+
+// Методи, които очакват да бъдат извикани
+// върху точно определен тип.
+var foo = {}
+Symbol.keyFor(foo); // TypeError: foo is not a symbol
+
+var foo = 'bar'
+Object.create(foo); // TypeError: "foo" is not an object or null
+</pre>
+
+<h3 id="Поправяне_на_грешката">Поправяне на грешката</h3>
+
+<p>За да оправите грешката в случай на указател, сочещ към стойност <code>undefined</code> или <code>null</code>, можете да използвате оператора <a href="/en-US/docs/Web/JavaScript/Reference/Operators/typeof">typeof</a>.</p>
+
+<pre class="brush: js">if (typeof foo !== 'undefined') {
+ // Сега знаем, че foo има определена стойност
+ // и можем да продължим.
+}</pre>
+
+<h2 id="Вижте_също">Вижте също</h2>
+
+<ul>
+ <li>{{jsxref("undefined")}}</li>
+ <li>{{jsxref("null")}}</li>
+</ul>