DEV Community

Cover image for Learning web development and JavaScript programming language
Ahmet Burhan Simsek
Ahmet Burhan Simsek

Posted on • Updated on

Learning web development and JavaScript programming language

JavaScript is one of the most widely-used programming languages in the world, and is essential for creating dynamic and interactive web pages. Learning JavaScript is a useful ability that can lead to a variety of chances in the web development industry, whether you are a novice or an experienced developer. The fundamentals of JavaScript, the advantages of learning it, and some tools and advice to help you get started with studying this potent language are all covered in this article. We’ll also look at some of the popular frameworks and tools for JavaScript development and discuss how they might improve the effectiveness and efficiency of your development process. This post is for you whether you’re trying to create your first website or if you’re an experienced developer looking to learn JavaScript.

First let’s start from web development concept.

What is web development ?

The process of building and maintaining websites and web applications is known as web development. It includes a broad range of activities and technology, such as:

  • Front-end development: The process of developing a website’s or web application’s user interface and user experience. For the site to be dynamic and responsive, the visual layout and design must be created using languages like HTML, CSS, and JavaScript.

  • Back-end development: The process of developing a website or online application’s server-side logic and functionality is known as back-end development. Working with programming languages like C#, Python, Ruby, and PHP is part of this.

  • Database management: Creating, maintaining, and querying databases to store and retrieve data for a website or web application is known as database management. Working with solutions like MsSQL, MySQL, MongoDB, and SQLite is part of this.

  • Web hosting: Making a website or web application accessible to internet users is known as web hosting. Server setup and web hosting services are included in this.

  • Optimization: A website’s or web application’s performance can be improved through optimization. Using a Content Delivery Network (CDN), minifying code, and compressing pictures are some examples of how to do this.

Web development is a constantly evolving field, and new technologies and best practices are always emerging. When working as a web developer, you might collaborate with other programmers to build complex web applications or work alone to make straightforward websites.

What is Javascript ?

Programming language JavaScript is primarily used to develop dynamic user interfaces and interactive front-end web applications. It is a scripting language that enables web designers to include dynamic elements like form validation, image sliders, and interactive maps on websites.

Because JavaScript is an event-driven language, it can react to user interactions as well as other events like page loads and clicks. Event listeners, functions that are called in response to particular events, are used to accomplish this.

JavaScript is also a single-threaded programming language, which means that it can only process one task at a time. But it makes use of a concurrency model called a “event loop” that enables non-blocking I/O operations. This implies that multiple tasks, such as user input and network requests, can be handled by JavaScript concurrently without the user interface becoming unresponsive.

Since JavaScript is a loosely typed language, variables do not always need to be declared with a particular data type and can store a variety of data at once. This has the potential to be both a benefit and a drawback because it increases coding flexibility while also making debugging more challenging.

JavaScript can also be used on the server-side using technologies like Node.js, which allows for full-stack JavaScript development. This means that the same language can be used for both the front-end and back-end of a web application, making it a popular choice for web developers.

JavaScript is a popular choice for creating web applications because it can be directly incorporated into HTML and CSS and run in the client’s web browser. Additionally, it is frequently combined with other web development tools like HTML, CSS and web frameworks like Angular or React.

In general, JavaScript is a strong and adaptable programming language that is frequently used to create dynamic, interactive web applications. It has a sizable and vibrant community as well as a broad selection of libraries and frameworks that make it simple to create sophisticated web applications.

What are the benefits of learning JavaScript ?

There are several benefits to learning JavaScript, such as:

  • High Demand: One of the most popular programming languages in use today, JavaScript is highly desired by employers. All of the main web browsers support this flexible language, which can be used for both front-end and back-end development.

  • Flexibility: A wide variety of web applications, from straightforward static websites to intricate interactive ones, can be made using JavaScript. Additionally, it can be used to make desktop, mobile and browser extensions.

  • Popularity: There are many resources available for learning JavaScript, troubleshooting issues and keeping up with new developments because there is a sizable and active community of developers.

  • Job Opportunities: As a JavaScript developer, you can work in various fields such as web development, mobile app development and even machine learning or artificial intelligence.

  • Better understanding of the web: Knowing JavaScript makes it easier to comprehend how the web, browsers and ways to interact with the web more effectively.

JavaScript is a flexible, in-demand language with a variety of applications, so learning it can be a great investment for anyone looking to work in web development or any related field.

How popular is JavaScript in development field ?

JavaScript is one of the most widely-used programming languages in the world. According to the 2022 Stack Overflow Developer Survey, JavaScript is the most popular programming language, with more than 65% of developers reporting that they use it. (Ref: https://survey.stackoverflow.co/2022/)

Top 10 programming languages rated in the StackOverflow Developer Survey 2022

JavaScript is mainly used for front-end web development, but thanks to tools like Node.js, it can also be used for back-end web development. JavaScript has grown in popularity in web development thanks to the emergence of frameworks and libraries like React, Angular and Vue.js that allow programmers to create intricate and responsive web applications.

JavaScript consistently ranks in the top 10 of most popular programming languages, according to the TIOBE Index, which measures the popularity of programming languages based on the volume of search engine results.

The top 10 most popular programming languages in early 2023 are:
1- Python (.py)
2- C (.c)
3- C++ (.cpp)
4- Java (.java)
5- C# (.cs)
6- Visual Basic (.vb)
7- JavaScript (.js)
8- SQL (.sql)
9- Assembly Language (.asm)
10- PHP (.php)

Note that the order of each language might vary based on the metrics used for measuring popularity. (Ref: https://www.tiobe.com/tiobe-index/)

JavaScript is a flexible language for developing web applications that can be accessed by a variety of users because it is supported by all major web browsers.

In conclusion, JavaScript is one of the most well-liked and in-demand programming languages in the world. It has numerous uses in the creation of websites, mobile applications and more.

Under which circumstances JavaScript is needed?

JavaScript is primarily used for creating interactive front-end web applications and dynamic user interfaces. Some common use cases for JavaScript include:

  • Creating interactive forms: JavaScript can be used to create interactive forms, validate user input, run calculations, and give users immediate feedback.

  • Creating dynamic user interfaces: A website can be made more interesting and interactive by adding animations, image sliders, and other dynamic effects using JavaScript.

  • Creating single-page web applications: Web applications that dynamically update and change content without requiring a page refresh can be made using JavaScript.

  • Accessing and manipulating the Document Object Model (DOM): JavaScript can be used to access and manipulate the elements of a web page, making it possible to create dynamic and interactive web pages.

  • Making HTTP requests: A web page can retrieve or send data without refreshing by using JavaScript to make HTTP requests to a server.

  • Creating browser extensions: JavaScript can be used to create browser extensions that can add new features and functionality to a web browser.

  • Creating mobile apps: Mobile app development using JavaScript is possible by the frameworks like React Native, which enables developers to create mobile apps with using JavaScript.

  • Creating desktop apps: JavaScript can be used to create desktop apps using technologies like Electron, which allows developers to build cross-platform desktop apps using web technologies.

  • Machine learning: By using libraries like TensorFlow.js and Brain.js, JavaScript can be used to create machine learning models that can be run directly in the browser.

What are the resources to learn JavaScript ?

There are many resources available for learning JavaScript, including online tutorials, video courses and books. Some popular options are:

It’s also a good idea to practice writing JavaScript code by building small projects or working on exercises.

Additionally, you can find a mentor who can offer advice and respond to any questions you may have along the way, or you can join online communities.

What is needed to know while learning JavaScript ?

In order to become proficient in JavaScript, you will need to learn the basics of web development.

  • HTML (Hypertext Markup Language) and CSS (Cascading Style Sheets): A web page’s structure and design are created using these languages. While CSS is used to style the elements and produce an aesthetically pleasing layout, HTML defines the elements and their content, providing the page’s structure.

  • The Document Object Model (DOM): The DOM, which is used by JavaScript to access and modify web page elements, is a representation of a web page in the form of a tree-like structure. For web pages to be dynamic and interactive, it is imperative to understand the DOM.

  • Web developer tools: The majority of online browsers include built-in developer tools for inspecting and troubleshooting web pages. These tools can be quite beneficial for diagnosing issues and understanding how a web page is produced.

  • Browser compatibility: JavaScript code may be displayed differently by different web browsers. It’s crucial to be aware of these variations and have the skills necessary to build code that is compatible with a variety of browsers.

  • Libraries and frameworks: There are a lot of libraries and frameworks out there that can make development easier and offer more features and functionality. React, Angular, and Vue.js are some popular frameworks, whereas jQuery, Lodash, and Moment.js are some of the well-known libraries.

  • Asynchronous programming: Despite being a single-threaded language, JavaScript uses a “event loop” to handle numerous processes at once. It’s important to understand how promises, async-await and callback functions work in JavaScript when dealing with asynchronous programming.

  • Security: JavaScript is client-side programming, so it’s critical to know potential security issues and understand how to design secure code.

Remember that learning JavaScript and web development is a continuous process, and new technologies and best practices are constantly being developed. As you develop your knowledge and skills, it’s critical to keep studying and exercising.

Let’s starts with the basics of web development then;

What is HTML (Hypertext Markup Language) ?

The standard language for building a web page’s structure and content is called HTML (Hypertext Markup Language). The headings, paragraphs, images, and links on a web page are all defined using tags and attributes in HTML. It provides the structure of the page by defining the elements and their content.

Here’s an example of a simple HTML document:

<!DOCTYPE html>
<html>
<head>
<title>My Web Page</title>
</head>
<body>
<h1>Welcome to my web page</h1>
<p>This is a simple web page created with HTML.</p>
<img src="https://picsum.photos/100/100" alt="Random Image">
<a href="https://www.example.com">Go to Example.com</a>
</body>
</html>

This is a simple example of an HTML document that creates a web page with a heading, a paragraph, an image and a link. You can test the code with saving into a file with .html format (i.e: mypage.html) with using a text editor (i.e: notepad).

If you need to know much more details about the code above, here is the detailed description 👇

The first line, <!DOCTYPE html>, is the document type declaration, which 
tells the web browser that this is an HTML5 document.

The <html> tag indicates the start of an HTML document. All the content of 
the HTML document should be placed between this tag and its closing 
tag </html>.

The <head> tag contains information about the document that is not 
displayed on the web page, such as the title of the page, meta data and 
links to stylesheets and scripts. Inside the head tag, there is the 
<title> tag which contains the text that will be displayed on 
the browser tab.

The <body> tag contains the content of the web page that will be displayed 
in the browser window. Inside the body tag, there are several tags that 
are used to create the structure and content of the web page:

The <h1> tag creates a heading, the text inside the tag will be displayed 
as a heading on the web page.

The <p> tag creates a paragraph, the text inside the tag will be displayed 
as a paragraph on the web page.

The <img> tag is used to embed an image in the web page, the src attribute 
is used to specify the URL of the image file, the alt attribute is used 
to provide alternative text for the image in case the image cannot be 
displayed.

The <a> tag creates a hyperlink, the href attribute is used to specify 
the URL of the link, the text inside the tag will be displayed as a 
link on the web page.
Enter fullscreen mode Exit fullscreen mode

Output of the HTML code given as example

What is CSS (Cascading Style Sheets) ?

A web page’s design and layout can be added using the language known as CSS (Cascading Style Sheets). It enables you to manage how a web page’s visual elements such as color, typeface and spacing are displayed. A web page’s layout and design can be made aesthetically appealing using CSS.

Here’s an example of a simple CSS stylesheet 👇

body {
     background-color: #f0f0f0;
     font-family: Arial, sans-serif;
     }

     h1 {
       color: blue;
       text-align: center;
     }

     p {
       font-size: 18px;
       line-height: 1.5;
     }
Enter fullscreen mode Exit fullscreen mode

This CSS stylesheet will change the visual presentation of the elements on the web page, the background color of the page will be light gray, the text inside the h1 elements will be blue and centered, and the text inside the p elements will be 18px with 1.5 line height.

The body selector targets the <body> element in the HTML document, and the 
styles inside the curly braces {} are applied to it.

background-color: #f0f0f0; sets the background color of the body element 
to a light gray color, it uses the hexadecimal color code to define 
the color.

font-family: Arial, sans-serif; sets the font-family for the text inside 
the body element to Arial, if Arial is not available it will use the 
default sans-serif font.

The h1 selector targets all <h1> elements in the HTML document, and 
the styles inside the curly braces {} are applied to them.

color: blue; sets the color of the text inside the h1 element to blue.

text-align: center; aligns the text inside the h1 element to the center.

The p selector targets all <p> elements in the HTML document, and the 
styles inside the curly braces {} are applied to them.

font-size: 18px; sets the font size of the text inside the p element to 
18 pixels.

line-height: 1.5; sets the line height of the text inside the p element 
to 1.5 times the font size.
Enter fullscreen mode Exit fullscreen mode

Keep in mind that this is just a simple example, there are many other properties and selectors available in CSS that can be used to control the layout and design of a web page.

To apply the CSS styles to a HTML document by saving the CSS styles code into another file such as “style.css”,then you can link the CSS file (style.css) to the HTML file using a link tag in the head section of the HTML file.

<link rel="stylesheet" type="text/css" href="styles.css">
Enter fullscreen mode Exit fullscreen mode

Or you can include the CSS styles directly inside the HTML file using <style> tag in the <head> section of the HTML file.

<!DOCTYPE html>
<html>
  <head>
<title>My Web Page</title>
<style>
  body {
  background-color: #f0f0f0;
  font-family: Arial, sans-serif;
  }
  h1 {
  color: blue;
  text-align: center;
  }
  p {
  font-size: 18px;
  line-height: 1.5;
  }

</style>
  </head>
  <body>
<h1>Welcome to my web page</h1>
<p>This is a simple web page created with HTML.</p>
<img src="https://picsum.photos/100/100" alt="Random Image">
<a href="https://www.example.com">Go to Example.com</a>
  </body>
</html>
Enter fullscreen mode Exit fullscreen mode

Output of the HTML and CSS code given as example

Alright, i believe you have some idea about HTML and CSS which are the basics of web development. So now let’s start to talk much technical about JavaScript.

What are the basics and commons of JavaScript ?

It’s necessary to know the main basics and core JavaScript ideas when learning the language by followings:

  • Variables: Variables are used to store data in JavaScript. Variables are declared using the keyword “var”, “let” or “const” and can be assigned a value using the assignment operator =. The variable can be used to store any type of data, like strings, numbers, booleans, arrays and objects.

  • Data types: JavaScript has several data types, such as strings, numbers, booleans and objects. Understanding these data types and how to work with them is important when writing JavaScript code.

  • Operators: Operators are used to perform operations on variables and values. JavaScript has several types of operators including mathematical, comparison, logical and assignment operators.

  • Conditional statements: Conditional statements are used to make decisions in JavaScript. The most common conditional statement is the if-else statement, which allows you to execute different code based on whether a certain condition is true or false.

  • Loops: Loops are used to repeat a block of code a certain number of times. JavaScript has two types of loops: for and while loops.

  • Functions: Functions are reusable blocks of code that can be executed multiple times. Functions are defined using the keyword “function” and can accept parameters and return a value.

  • Arrays: Arrays are used to store lists of data. JavaScript arrays are a type of object and can hold multiple values of any data type.

  • Objects: Objects are used to store collections of data. JavaScript objects are a type of data structure that can store multiple properties, which are similar to variables, and methods, which are similar to functions.

  • Events: Events are actions that can be detected by JavaScript, such as a button click, a page load, or a form submission. Event listeners can be added to elements to execute a function when a specific event occurs.

  • DOM: The Document Object Model (DOM) is a representation of a web page in the form of a tree-like structure, and it is used by JavaScript to access and manipulate the elements of a web page. Understanding the DOM is essential for creating dynamic and interactive web pages.

Here’s an example of JavaScript code that demonstrates some of the common and basic concepts I mentioned above 👆:

// Declare a variable and assign a string value
let message = "Hello World!";

// Declare a variable and assign a number value
let num1 = 10;
let num2 = 20;

// Use mathematical operators to perform calculations
let result = num1 + num2;
console.log(result); // Output: 30

// Use comparison operators to compare values
if (num1 > num2) {
  console.log(num1 + " is greater than " + num2);
} else {
  console.log(num2 + " is greater than " + num1);
}
// Output: 20 is greater than 10

// Use a loop to iterate through an array
let numbers = [1, 2, 3, 4, 5];
for (let i = 0; i < numbers.length; i++) {
console.log(numbers[i]);
}
// Output: 1 2 3 4 5

// Define a function and call it
function greet() {
console.log(message);
}
greet(); // Output: "Hello World!"

// Create an object
let person = {
name: "John Doe",
age: 30,
speak: function() {
  console.log("My name is " + this.name + " and I am " + this.age 
              + " years old.");
}
};
console.log(person.name); // Output: "John"
console.log(person.age); // Output: 30
person.speak(); // Output: "My name is John and I am 30 years old."
Enter fullscreen mode Exit fullscreen mode

In this code; we first defined some variables, then we did some calculation and comparison using mathematical and comparison operators, then we iterated through an array using a for loop, defined a function and called it, then we created an object called person with properties and methods, then we accessed the properties and called the method using the dot notation ‘.’

The majority of the fundamental and widely used JavaScript concepts are covered, including variables, data types, operators, conditional statements, loops, functions, arrays, objects, properties, and methods, events, and DOM manipulation. This code also has comments that describe what each section of the code does, making it simple for someone who is not familiar with JavaScript to understand.

Remember that JavaScript offers a lot more to study and explore; this is merely a basic example.

A brief explanation for Document Object Model (DOM)

The Document Object Model (DOM) is a programming interface for HTML and XML documents. It represents the structure of a document in a tree-like format, with each element, attribute, and piece of text in the document being represented as an object. The DOM allows you to programmatically access and manipulate the contents of a document, such as adding, modifying, or deleting elements, changing the styles of elements or responding to user events.

The DOM is used by JavaScript to access and manipulate the elements of a web page, allowing you to create dynamic and interactive web pages. For example, you can use the DOM to change the text inside an element, change the styles of an element, or add a new element to the page.

When a web page is loaded by a browser, the browser creates a DOM of the page, and you can use JavaScript to access and manipulate the elements of the DOM. The DOM is a standard that is supported by all major web browsers and allows for consistent access to the elements of a web page, regardless of the browser being used.

In a nutshell; the DOM is a programming interface that allows you to access and manipulate the contents of an HTML or XML document and it’s the foundation for creating dynamic and interactive web pages using JavaScript.

What are the web developer tools and how to use them ?

Developers can inspect, troubleshoot, and test web pages using browser-based web developer tools. They can be used to see and edit the HTML, CSS, and JavaScript of a web page as well as to test the functionality and compatibility of a web page. They are built into modern web browsers like Chrome, Firefox, and Safari.

Here is a brief explanation of some of the common features of web developer tools:

  • Inspect Element: Allows you to view and edit the HTML and CSS of a web page by selecting an element on the page. It also allows you to see the layout, styles, and computed styles of the selected element.

  • Console: Allows you to interact with JavaScript on a web page by writing and executing code, displaying output and errors, and testing code snippets. It is a powerful debugging tool, you can use it to check the value of variables, output messages, and run JavaScript code on the fly.

  • Network: Allows you to monitor and analyze network requests made by the browser, including the headers, status codes, and timings of each request. This can be useful for debugging performance issues and identifying slow-loading resources.

  • Performance: Allows you to analyze the performance of a web page, including the load times, rendering times, and JavaScript execution times. It can help you identify and fix performance bottlenecks in your code.

  • Application: Allows you to inspect and interact with the data stored in browser storage, such as cookies, local storage, and indexedDB. This can be useful for debugging and testing web applications that use client-side storage.

The developer tools can be opened by pressing the F12 key (in most browsers) or by choosing “Developer Tools” from the browser’s menu, or you can simply right-click anywhere on the web page and choose “Inspect Element.” For each feature, such as “Elements,” “Console,” “Network,” “Performance,” and “Application,” the developer tools will open as a panel at the bottom or side of the browser window. You may access the various capabilities and utilize them to investigate, debug, and test your web page by navigating between the tabs.

Screenshot of the developer tools in Google Chrome

What do i need to do JavaScript programming ?

As environmental setup needs, JavaScript does not need too much installations or preparation. It is very lightweight to start programming.

To begin programming with JavaScript, you will need the followings:

  • A Text Editor: You will need a text editor to write and save your JavaScript code. Some popular text editors for JavaScript development include Sublime Text, Atom, Visual Studio Code, and Notepad++.

  • A Web Browser: JavaScript code runs in the browser, so you will need a web browser to test your code. Popular web browsers include Google Chrome, Mozilla Firefox, Microsoft Edge, and Safari.

  • A Connection to the Internet: Some JavaScript development tools and libraries are available online, so you will need an internet connection to access them.

Once you have these three things, you can start writing and testing your JavaScript code. You do not need any specific operating system or hardware to run JavaScript, as long as your computer can run a web browser and a text editor, you should be able to run JavaScript.

Finally, let’s append to add some interactivity to the HTML and CSS code we wrote above with using JavaScript ✅

<!DOCTYPE html>
<html>
  <head>
<title>My Web Page</title>
<style>
  body {
  background-color: #f0f0f0;
  font-family: Arial, sans-serif;
  }
  h1 {
  color: blue;
  text-align: center;
  }
  p {
  font-size: 18px;
  line-height: 1.5;
  }
</style>
  </head>
  <body>
<h1>Welcome to my web page</h1>
<p>This is a simple web page created with HTML.</p>
<img src="https://picsum.photos/100/100" alt="Random Image">
<a href="https://www.example.com">Go To Example.com</a>
<script>
  // Get the heading element
  var heading = document.querySelector("h1");

  // Add an event listener to the heading that changes the text color on mouseover
  heading.addEventListener("mouseover", function() {
  heading.style.color = "red";
  });

  // Add an event listener to the heading that changes the text color back on mouseout
  heading.addEventListener("mouseout", function() {
  heading.style.color = "blue";
  });
</script>
  </body>
</html>
Enter fullscreen mode Exit fullscreen mode

Our JavaScript code is added between <script> </script> tags.

This JavaScript code changes the color of the h1 **heading to red when the user’s mouse pointer is over the **h1 heading and change it back to blue when the user’s mouse pointer leave the h1 heading.

The code first selects the h1 heading element using the querySelector 
method. querySelector is a method of the document object that allows you 
to select the first element that matches a given CSS selector.

Next, it adds two event listeners to the heading element, one for mouseover 
event and another for mouseout events.

The first event listener is triggered when the mouse pointer is moved over 
the heading element and it changes the text color of the heading element 
to red by setting the color property of the style object of the heading 
element to "red".

The second event listener is triggered when the mouse pointer is moved out 
of the heading element and it changes the text color of the heading element 
back to blue by setting the color property of the style object of the 
heading element to "blue".
Enter fullscreen mode Exit fullscreen mode

Screen recording for the HTML, CSS and JavaScript code above.

We have covered the fundamentals of JavaScript, a programming language that enables the development of dynamic and interactive web pages. We’ve also talked about the advantages of learning JavaScript, how to get started, and how common it is among developers. Basic HTML and CSS concepts and their use in web development were also taught. A programming interface for HTML and XML documents called the Document Object Model (DOM) and how JavaScript may be used to access and modify web page elements were also covered. We discussed the web developer tools, how to utilize them, and the prerequisite environments for beginning JavaScript development.

Finally we wrote some HTML and CSS code including JavaScript code as examples. All of these concepts are important for understanding how JavaScript works and how to use it to create interactive web pages and web applications.

I hope you learned something useful and interesting about JavaScript, HTML, CSS and web development. I wish you the best in your future adventures as a web developer and hope you now have a better understanding of how these technologies combine to produce dynamic and interactive web pages. Thank you for reading, and I look forward to assisting you if you have any JavaScript-related questions.

Latest comments (0)