DEV Community

Yahyah Ridwanullahi olanrewaju
Yahyah Ridwanullahi olanrewaju

Posted on

Move from been a Novice in JavaScript to Beginner in just 3weeks of JavaScript.

Hello dear, my name is Ridwanullahi known as whitecoode. I am a software developer, in this part of the lecture which marks the first part of the article we will be learning the introduction to javaScript, what can JavaScript be use for, and few examples. Now let get started;

What is JavaScript and what is it use for?
JavaScript is a scripting or programming language that allows you to implement complex features on web pages. It is a dynamic programming language that’s used for web development, in web applications, for game development, mobile application, Artificial intelligent (AI), desktop application and lots more. It allows you to implement dynamic features on web pages that cannot be done with only HTML and CSS. Example of where you can see a quick JavaScript functionality, you should try to click on the hamburger(☰) icons on your mobile view and if you are on a desktop try to collapse your window and resize it to mobile size to see the magic of JavaScript.

Now after we have know what JavaScript is all about, let's talk about JavaScript where-to.

JavaScript Where-to
I assume we have knowledge about HTML, so I am not going to talk about it in this section. JavaScript where-to means where are we going to write our JavaScript code or where can we write JavaScript code. A JavaScript code can be written between an internal script tag or external script file.

Example
Internal Script tag

<script>//JavaScript code goes here</script>

NOTE: Internal Script tag can be placed in the , or in the section of an HTML page, or in both.

<!DOCTYPE html>
<html>
<head>
<title>Introduction to Javascript</title>
</head>
<body>
<h2>Demo JavaScript in Head</h2>
<script>
//JavaScript Code 
</script>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

OR

<!DOCTYPE html>
<html>
<head>
<script>
//JavaScript Code 
</script>
</head>
<body>
<h2>Demo JavaScript in Head</h2>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

External File (Script) means writing JavaScript in an external file by creating a script file, example create a script.js file in your visual studio code editor. Now that you have create the file you have successfully create an external script file for a JavaScript Script file.
External Script has a lot of advantage over the internal script, some of them are:

  • It separates HTML from JavaScript code.
  • It makes HTML and JavaScript easier to read and maintain
  • Its even speed up the page loads.

After creating the external script you now need to import to your HTML code using the same script tag but with additional attribute, <script src="script.js"></script>. Now we have successfully import or link our JavaScript code to our HTML code, so let start writing some cool code which is our first JavaScript code.

JavaScript variables
variables are containers for storing data. There are three(3) best way to declare a variable in javaScript which are:

  1. With var
  2. With let
  3. With const

After we know what variables are we can now learn about how we can use them. But before that we need to understand statement.
A statements are set of instructions to be executed by the computer to perform a specific task. A statement compose of Values, Operators, Expressions, Keywords, and Comments. Below is the syntax of how is looks like in real world:

var name = "whitecoode"; // decaling a variable
Enter fullscreen mode Exit fullscreen mode

Explanation: The var is a keyword, the name is the variable name, the = is an expression(assignment operator), the whitecoode is the value assigned to the name, the ;(semi-colons) separate JavaScript statement and // decaling a variable this is a comment.

Work to do
Create a JavaScript statement give the value of Hello! coode.

We will stopping here for awhile so take some rest and see you in the next part.

Follow me!!! to

Top comments (0)