Posts for Javascript

Regular Expressions (RegExp) in JavaScript

When working in any programming language, you may want to search characters within strings most of the time. It’s very easy to perform the following check; But, what you are searching for may not be equivalent to the entire content of the string. It may just be part of it – at the beginning, or end or just somewhere. In order to achieve this, Regular Expressions (short form – RegEx or RegExp) are used. What are Regular Expressions? These are sequence of characters which define a search pattern that can  be used on strings. How to Create a RegEx There are two methods involved in creating regular expressions which are: 1. Calling the constructor function of the RegExp object 2. Using a regular expression literal As seen above, the expression is declared between the slashes for literals while for the constructor function, the expression is declared as an argument of type string. The major difference between these two syntaxes is that expressions (like string template literals) can be used in the constructor function but not in the literal expression because it is fully static. Literal expressions are used when the regex is known before execution. But the first syntax is used when there is need to create a reg during run time (such as after taking user input). The expression ^jav matches strings which begin (^) with “jav“. We’d be looking at more ways of declaring expressions later in this article. Application of Regular Expressions Expressions can be used with test() and exec() methods of the RegExp object. test(): Here, you can use the expression to test a string. It returns true if it matches the string or false if otherwise. exec(): This method returns an array of information (index, input and group) and updates the lastIndex property of the regex object if it matches the string. Otherwise, it returns null. It can be used to search for multiple matches in a string. For these methods, the syntax for application is regex.method(string) . The method is applied to the declared expression and takes an argument of the string which it is tested on. Regex can also be used with match(), search(), replace() and split() methods of the String object. match(): If it matches, it returns […]

January 16, 2020 in Javascript & Tutorials

How to optimize Vue.js applications

Just like every other application out there that grows in size, Vue.js applications also deteriorate in performance as the application grows. In this article, we’ll briefly discuss some of the techniques in optimizing Vue.js applications. Let’s get cracking. The ways to optimize a Vue.js application Here are a few tips to make your Vue applications […]

January 5, 2020 in Tutorials & Vue

Understanding scope in JavaScript

JavaScript is a simple, partially easy to use language with broad attractions in the web development industry. Unfortunately, it is built upon a complex collection of language mechanics which without careful study will not be understood even by seasoned developers. It is even harder to learn JavaScript completely. In this article, we will focus on […]

December 29, 2019 in Code examples & Javascript

Understand Promises in JavaScript

You know that moment you promise to send your friends a Christmas gift and they have to wait for you to keep that promise(resolve), then further actions can be taken or if you break the promise(reject), they would like to know what happened (catch), so that they can plan what to do next or how […]

December 26, 2019 in Code examples & Javascript

Understanding Hoisting in JavaScript

This article is for JavaScript developers who want a deep understanding of the core concept of the language and how the javascript engine work. Though var and let are standard keywords for variable declaration in JavaScript, at the end of this tutorial, you will know why let is of more preference than var. Is it […]

December 21, 2019 in Code examples & Javascript

How to dynamically create reactive properties in Vue

One of the best features that JavaScript frameworks are known for is their reactivity and Vue is no exception. In this tutorial, we’ll be looking at how to add reactive properties in a component’s instance after initialization. Before we kick off Learn Vue.js and modern, cutting-edge front-end technologies from core-team members and industry experts with […]

December 21, 2019 in Tutorials & Vue

How to Modularize Javascript Code

Before we learn How to Modularize Javascript Code, we first need to understand what they are. Can you think of any complex system ranging from a bicycle to a more complex automobile engine? What is the common feature of these complex systems? These systems are made of individual parts with different functionalities interacting with one […]

December 20, 2019 in Javascript & Tutorials

Understanding Fetch() in JavaScript

The fetch()  method allows you to make network requests similar to XMLHttpRequest (XHR). The main difference between the Fetch API and XMLHttpRequest which was otherwise known as XHR is that the Fetch API uses Promises, which makes you write cleaner API calls, strictly avoiding callback hell and reducing the complexity of XMLHttpRequest. Basic Fetch Request […]

December 20, 2019 in Code examples & Javascript
Deven
Deven wrote

JavaScript Functional Programming Basics

JavaScript functions are first-class objects, which means functions possess the same properties as variables do. With the introduction of the latest JavaScript Syntax, a lot of improvements have been done to boost your JavaScript functional programming workflow, including arrow functions, promises, and the spread operator. So, What is JavaScript Functional Programming? JavaScript Functional programming is […]

December 16, 2019 in Code examples & Javascript

Writing cleaner code with higher-order functions

Higher-order functions in JavaScript simply put are functions that either return another function or take another function as an argument. There are built-in higher-order functions in JavaScript which we’ll be looking at in a bit, first, let’s look at the simplest example of a higher-order function: const add = (x)=>(y)=> x + y; As you […]

December 11, 2019 in Javascript & Tutorials

An in-depth view of Higher-Order functions

Introduction As complex as it may seem, higher-order functions are functions that either accepts a function as an argument or returns a function or does both. This is possible because, in JavaScript, functions are first-class citizens — they are treated as variables and can be passed as arguments to other functions and returned by other […]

December 5, 2019 in Javascript & Tutorials

How to build a Twitter bot with NodeJs

Building a Twitter bot using their API is one of the fundamental applications of the Twitter API. To build a Twitter bot with Nodejs, you’ll need to take these steps below before proceeding: Create a new account for the bot. Apply for API access at developer.twitter.com Ensure you have NodeJS and NPM installed on your […]

December 2, 2019 in Javascript & Node & Tutorials