Basic JavaScript for Beginners

Abdullah AL Habib
3 min readMay 6, 2021

Primitive Values

var bar = “Hero”;
console.log(bar);
bar.toUpperCase();
console.log(bar);
//Ans:
//Hero
//HERO

There are seven primitive data-type as there are:

  • string
  • number
  • boolean
  • undefined
  • symbol
  • null

Objects and Functions

Object and function are also value but they are not primitive. If I give an example I think it will be cleared

console.log({});
console.log([]);
console.log(x => x * 2);
//Ans:
//{}
//[]
//x => x * 2

Objects and Expression

you cannot share all your true feelings with your favorite person. In that way, javascript has some activities that which is acceptable. Such for example that

console.log(2+6)
//the answer is: 8

In the proposal, if it acceptable javascript gives the right answer. lastly, I can say that expression is like a question that javascript can give this answer.

Types of Values
if people want that they can research JavaScript. Brandan Eich made JavaScript. but after 25 years they able to succeed to make nine things. In which any type of website or any application can build by those nine such types.

Checking Type:

If we look closely, we’ll realize there are fewer than ten different types of values. Values of the same type behave in similar ways. If we want to check a value’s type, we can ask it with the typeof operator. JavaScript will answer our question with one of the predetermined string values, such as “number”, “string”, or “object”.

console.log (typeof (2)); // “number”console.log(typeof(“hello”)); // “string”console.log(typeof(undefined)); // “undefined”

Here, typeof (2) is an expression — and it results in the “number” value.

One of the cases below would break if we omitted the parens after typeof. Try to guess which one it is:

console.log (typeof ({})); // “object”console.log (typeof ([])); // “object”console.log (typeof (x => x * 2)); // “function”

Error handling, “try..catch”

No matter how great we are at programming, sometimes our scripts have errors. They may occur because of our mistakes, unexpected user input, an erroneous server response, and for a thousand other reasons.

But there’s a syntax construct try..catch that allows us to “catch” errors so the script can, instead of dying, do something more reasonable.

Syntax:

The try..catch construct has two main blocks: try, and then catch:

try {// code…} catch (err) {// error handling}

Cross-browser testing:

Cross-browser testing is the practice of making sure that the websites and web apps you create work across an acceptable number of web browsers. As a web developer, it is your responsibility to make sure that not only do your projects work, but they work for all your users, no matter what browser, device, or additional assistive tools they are using. You need to think about:

  • Different browsers are other than the one or two that you use regularly on your devices, including slightly older browsers that some people might still be using, which don’t support all the latest, shiniest CSS and JavaScript features.
  • Different devices with different capabilities, from the latest greatest tablets and smartphones, through smart TVs, right down to cheap tablets and even older feature phones that may run browsers with limited capabilities.
  • People with disabilities, who use the Web with the aid of assistive technologies like screen readers, or don’t use a mouse (some people use only the keyboard).

--

--