My Development Notes

Programming Made Easier


Category: JavaScript

  • Listening to user input using JavaScript

    Listening to user input using JavaScript

    You can listen to user inputs using various methods in JavaScript. Some of the most popular ones are given here with examples : Example 1 The value keyword can be used to capture the user input inside the DOM. Here’s how it works : Inside the JavaScript code block above you’ll see that we’ve used…

  • To Do List in JavaScript – Explanation

    To Do List in JavaScript – Explanation

    I’ve created this fully functional To-Do-List code in JavaScript and explained how each line of code works within the comments in this document. JavaScript Logic Here’s a simple and beginner friendly way to write the logic. First, the HTML file is given below : The HTML file above is pretty simple. Note that there’s a…

  • Callback functions in JavaScript

    To understand callback functions let’s write some very simple functions and see the expected output first : Example 1 Expected output of the above : Example 2 Expected output of the above : In both the examples above you can see that we have the same functions and we have only called the first and…

  • How to run JavaScript codes inside VS Code

    You can run JavaScript codes inside the Visual Studio Code’s in-built terminal. This saves time since you don’t have to open up an external browser every time to test-run your codes. Here are the steps involved : Step 1 You have to first check whether NodeJS is installed on your system. To check, just type…

  • How to Work with Strings in JavaScript

    Basics The various string methods in JavaScript are given here with examples : To change the case of a string : How to replace parts of Strings Here’re some examples to do so: We can also use replaceAll method to replace more than one occurrences in a string : Regular expressions can also be used…

  • Maps in JavaScript : Fundamentals with Practicals

    The Map is a data structure that maps values to keys. Data is stored inside a key value pair in Map. However, Maps and Objects are different. In objects, keys are generally strings(or symbols) but in Maps there can be any type of keys (objects, strings, arrays or even other maps). To create a new…

  • Sets in JavaScript – Basics and Used Cases

    Sets are a collection of unique values which never stores any duplicates. They are used to iterate through and detect multiple occurrence of the same element inside any variable, array, strings or object. The new Set() method creates a new set. To return the number of elements inside a set use size property : To…

  • Array and Object Destructuring using JavaScript

    In destructuring, we break down the data inside a complex array or object into simpler fragments. Here, we extract data from an array or object and then store them in a variable defined by us. Sometimes it’s also called ‘unpacking’. Array Destructuring Here are some examples to illustrate the same : Now, here’s a rather…

  • Basics of JavaScript Modules using Import and Export keywords

    Basics of JavaScript Modules using Import and Export keywords

    A Brief Explanation Modules are actually certain independent pieces of code syntax which can be used and reused in certain other places, when required. The reason we use modules is because they help to segregate code segments into different files, folders or pages. You don’t really need to write one single long page of JavaScript…

  • How to use quotes within a string in JavaScript

    How to use quotes within a string in JavaScript

    The best thing to do in order to use quotes within a string in JavaScript is to use backticks (` `) instead of single or double quotes. Let’s see this with an example: Another way is to use the backward slash (\) in the following way: