Errors of JavaScript

JS Function, Object, Errors, Coding Style, Cross Browsing……All in one😍

M SAON
3 min readNov 4, 2020

Javascript is a lightweight, interpreted, or just-in-time compiled programming language with the first-class function. It is also a full-fledged dynamic programming language that can interact with a website. It was invented by Brendan Eich.

Primitive Values

=============

  1. undefined(undefined), used for the unintentionally missy value.
  2. Null(null), used for intentionally missing values.
  3. Booleans(true and false), used for logical operations.
  4. Numbers(-100,3.21416 and others), used for math calculations.
  5. Strings(“hello”, “America”, and others), used for text.
  6. Symbols(uncommon), used for hide implementation details.
  7. BigInts(uncommon and new), used for math on big numbers.

Objects and Functions

==================

  1. Objects({} and others), used to group related data and code.
  2. Functions(x => x*2 and others), used to refer to code.

console.log(typeof([])); // “object”
console.log(typeof(new Date())); // “object”
console.log(typeof(/(hello|goodbye)/)); //
“object”

Error Handling, “try…catch”

=====================

Error showing for our mistakes, and unexpected user input, erroneous server response, and for a thousand other reasons.

Normally, a script immediately stops in case of an error, printing it to console.

But try…catch that allows “catch” error so it can do something more reasonable.

try() {

// code…

} catch (err) {

// error handling

};

That means this works in this such way which I describe bellows: If there were no errors, then catch(err) is ignored and skipping the catch with publishing the try() field.

if an error occurs, then the try() execution is stopped and flows to the catch(err). The err variable contains an error object with details.

How to Write Code for JavaScript?

===========================

coding Style

Our Code must be clean and easy to read as much as possible. That is actually part of programming skill and it also helps to make human-readable. If you are a JavaScript prommer then must follow the undermentioned valuable point for coding:

  1. Must give a space between parameters.
  2. No space between the function name and parentheses between the parentheses and the parameter.
  3. Curly brace { on the same line, after space.
  4. Indentation 2 space after writing a function.
  5. Spaces around operators.
  6. A space after for/if/while...
  7. After every statement a semicolon is mandatory.
  8. An empty line between logical blocks.
  9. Lines are not very long.
  10. } else { without a line break
  11. Spaces around a nested call.
  12. comments single line by //code and multiline /*code */

Cross Browser Testing:

==================

Cross-browser testing is making sure that the websites and web apps created by you which is an acceptance by any web browsers.

The different browser used by people regularly and different devices with different capabilities based websites test are required before publishing your website or Mobile applications.

Remember that developers are not users. Must follow the bellows:

  1. Test it must be a couple of stable browsers on the system, like Firefox, Safari, Chrome, or IE/Edge.
  2. Do some lo-fi accessibility testing.
  3. Test on a mobile platform such as Android or iOS.

--

--

M SAON
0 Followers

Programmer || Author || Entrepreneur