DEV Community

Sumedha Biswas
Sumedha Biswas

Posted on

What You Know About JavaScript Tutorial And What You Don't Know About JavaScript Tutorial

  • Introduction to JavaScript 

JavaScript is the main language used to build web pages, especially on the client side. There are many JavaScript frameworks available on the market, but most of them are aimed at developing web apps. If you are not familiar with JavaScript or have never written a single line of JavaScript before then, this blog will probably be very interesting for you.

It is built on top of the C++ language. It has a large number of features and is used in a wide range of industries. It can be used to build web applications, games, data processing apps, websites and so on.

  • 5 things you must know about JavaScript Tutorial 

For any web developer, knowing JavaScript is absolutely mandatory. Knowing a little bit of HTML or CSS is no longer going to help you get through anywhere in your career as a JavaScript developer. 

In this blog, we'll address some of the most common things that you must know, and you might not know as a new JavaScript developer. Here are a few things that any new JavaScript developer should be aware of:

  • You can add properties to almost everything

  • Functions are objects

  • Automatic type conversions

  • Variable scoping

  • Variables that aren't explicitly declared can be global

  • You can add properties to almost everything

Boolean, Number and String are the only primitive data types in JavaScript. Other than these, you will be able to add a property to everything until they are undefined or have a null value. 

For example, String, even though it is a primitive type ("hi"), there exists another type of String in JavaScript, which is an object (new String("hi")). The javascript object is a fundamental part of javascript programming. It is used to create and manipulate strings, numbers, arrays, and many other types of objects.

  • Functions are objects

Most languages support functions as values. But since considering you are from totally a different background, you might not be aware of this. In simple words, a function is an object that performs one or more tasks. They can be small pieces of code to solve a specific problem, like calculating the distance between two objects, or complex algorithms like Newton's laws.

Functions can also be defined as objects that can be used by other objects in JavaScript. They can be used to solve certain problems, often without any programming knowledge. Examples of functions are average, mean, maximum, round and others.

Figure 1. Source: Google

  • Automatic type conversions

In the past, developers had to write their own code to do automatic type conversions. This was a pain as developers had to write their own code for the conversion of characters and numbers into other characters or numbers. Now with automatic type conversions, developers can focus on what they are good at - writing clean code.

Figure 2. Source: Google

For example, with the help of automatic type conversions, JavaScript will be able to read text from different languages and convert it into one programming language.

  • Variable scoping

Variable scoping in JavaScript is a very common and common practice. It's so obvious and frequently used that you may even forget that it exists. It is a feature of JavaScript that allows you to write code that runs in multiple locations and run at the same time.

Figure 3. Source: Google

Variable scoping is useful when you need to be able to adapt your code to different circumstances. For example, you could want a variable scope for dynamic variables and constant values but not for global variables and constants.

This feature allows you to write:

var $page = "page"; $page = 'this is a constant' ; $page = '$GLOBALS[' + $GLOBALS[$GLOBALS] + ']=' ; var $count = 10; var count = 0; function count() { // ... } count(); // Prints 1

While there are many other features like this one, this example focuses on the variable.

  • Variables that aren't explicitly declared can be global.

Global variables are very useful for programmers. However, there are situations where they can be hazardous to use. These situations may arise in the programmer's code when you forget to use the 'var' keyword for a variable while wrapping up a function. So this is when JavaScript assumes the variable as Global. Variable names/identifiers are an important part of any programming language.

There is no such thing as "data" and "character" in object-oriented languages because objects do not really object but are just collections of data. So if you do not define them explicitly in the scope of your function, they become a global variable.

  • 3 things you might not know about JavaScript Tutorial 

Even though JavaScript is widely used nowadays and everything is quite open and common for most developers, there are still some points which many developers like you who are at the beginning of their learning process might not know.

  • The -0

  • NaN (Not a number) is a special number!

  • Some cool icons using HTML Entity

  • The -0

Well, it is pretty obvious that many of you might not be aware that there is a -0 value in JavaScript. Even though we use the +0 as a default value, but the -0 is also present in the JavaScript language. Both +0 and -0 are of the same/equal value, and hence only 0 is returned as a result.

Figure 4. Source: Google

  • NaN (Not a number) is a special number!

JavaScript is one of the most popular programming languages in the world. It has been used to create web pages for over a decade and continues to grow in popularity. However, it is not well known among computer users, and only a minority of developers would know about it.

A NaN (Not a number) is a number with an unknown value. That is why it needs to be represented by the letter NaN (Not a number). You can use the code 'typeof NaN' and see yourself what it returns, and also, just for a piece of additional information, the result for 'NaN==NaN' always returns a false value in Javascript.

Figure 5. Source: Google

  • Some cool icons using HTML Entity

As we all know, while developing a website, creativity plays a very vital role in terms of client satisfaction. Using the same old structure and codes for outdated icons makes your website definitely visually unappealing. 

So it is always better to invoke the HTML Entity in your codes to add some really cool icons to your JavaScript projects. You can always use the following code to use the desired icons.

Figure 6. Source: Google

  • Conclusion

With the rapid development of JavaScript, it is surprising that there are still some people who think that programming is not possible in general. But, you can still learn how to program with JavaScript and do simple stuff like creating graphs or graphs of numbers from other websites providing free JavaScript tutorials. 

This blog presents different unusual ways by which JavaScript can be used for various tasks. There are still many opportunities for developers to use JavaScript for their applications and websites - it's just that they have not yet used any of them because they do not have basic knowledge about JavaScript or have not found an easy way or tutorial to use them in their applications or websites.

Top comments (1)

Collapse
 
uciharis profile image
the hengker

cool. there are no end to learn javascript, their world is too wide