Posts for Code examples

This section provides you small and well-documented Code examples for Beginners, Clear Your basic Concepts using this section
Deven
Deven wrote

​​How to make a POST JSON request with Axios

In this article, you will learn about Post JSON request with Axios. In JavaScript, Axios is a library that is used to make HTTP requests from Node and is also used in front-end applications. It is a promise-based API. You can Post JSON requests with Axios by calling axios.post() method. This method simply expects two […]

December 1, 2021 in Code examples
Deven
Deven wrote

How to get selected option value in jQuery

In this article, you are going to learn about how to get selected options value in jQuery. jQuery is a speedy, lightweight, and easy-to-learn JavaScript library. With this library, you can manipulate the HTML DOM tree as well as event handling and bring interactivity to your web page. jQuery provides lots of library methods, :selected […]

November 1, 2021 in Code examples
Deven
Deven wrote

How to handle Axios error

In this article you will learn about how to handle axios error. In JavaScript, Axios is a promise-based API, which is basically a JavaScript library. It is mainly used to make HTTP requests from Node and is also used in front-end applications. As Axios requests is a promise-based API, it lets you perform promise chaining […]

October 29, 2021 in Code examples
Deven
Deven wrote

How to continue forEach in javaScript

In this article, you will learn about how to continue forEach loop in javaScript. In JavaScript, forEach loop is considered as an array method that executes a custom callback function on each item in an array. You can use forEach loop only on the array. Let’s see a forEach loops example first: Suppose you have […]

October 27, 2021 in Code examples
Deven
Deven wrote

How to use Object.keys in forEach

In this article, you will learn about how to use Object.keys() in forEach. In JavaScript an Object is a data type that is used to store various types of collection and complex entities. forEach loop is only used on the array. You can not use it to iterate the properties of an Object directly. To […]

October 27, 2021 in Code examples
Deven
Deven wrote

How to break forEach in JavaScript

In this article, you will learn about how to break forEach loop in JavaScript. In JavaScript, forEach loop is considered as an array method that executes a custom callback function on each item in an array. You can use forEach loop only on the array. Let’s see a forEach loops example first: Suppose you have […]

October 27, 2021 in Code examples
Deven
Deven wrote

How to use string interpolation in Javascript

In this article, you will learn about JavaScript string interpolation. In JavaScript, string interpolation is the process of evaluating a string literal containing one or more placeholders and expecting the result in which the placeholders are replaced with their desired values. In simple terms, it is the process of embedding an expression into part of […]

October 27, 2021 in Code examples
Deven
Deven wrote

How to flatten an array in JavaScript

In this article, you will learn about how to flatten an array in JavaScript. In JavaScript, an array is used to stores multiple data in a single variable. Array can be one dimensional or multi-dimensional. Flatten an array in JavaScript means reduce the multiple dimensions of array into an single array. Suppose you have a […]

October 27, 2021 in Code examples
Deven
Deven wrote

How to select multiple lines in VS code

In this article, you will learn about how to select multiple lines in VS code. Visual Studio Code is a powerful source code editor which is developed by Microsoft. It is a cross-platform desktop app that can be run on Windows, Mac or, Linux. VS code comes with lots of functionalities that let you write […]

October 27, 2021 in Code examples
Deven
Deven wrote

How to check a value contains in Javascript array

In this article, you will learn about how to check a value that contains in the JavaScript array. An array in JavaScript can be stored different elements into a single variable. In JavaScript, elements can be a primitive value like String, Number, etc. JavaScript lets you check a value that exists in the array or […]

October 27, 2021 in Code examples
Deven
Deven wrote

How to check Javascript null

In this article, you will learn about how to check null in JavaScript. JavaScript comes with a special type of value named null. In JavaScript, it is a primitive type value and represents an intentional absence of any Object value. Null is considered as a boolean type value and by default, it is treated as […]

October 27, 2021 in Code examples
Deven
Deven wrote

JavaScript Submit form example

Forms are an integral part of any website. Most websites often contain the Contact Us form. Forms collect the user information & send it to a server to store it in a database. In today’s post, we are going to learn how you can collect the user information via HTML forms & submit it to […]

October 19, 2021 in Code examples
Deven
Deven wrote

Jquery Select all checkbox example

A checkbox is an HTML input that lets a user select one or more options of a limited number of choices. Checkboxes are defined using <input type=”checkbox”>. Sometimes we need to automatically check/uncheck all checkboxes when a single checkbox is checked / unchecked. For eg: A list of 5 items inside a combo, the user can […]

October 19, 2021 in Code examples
Deven
Deven wrote

Node.js Express redirect example

HTTP Redirects are used to send users’ browsers to another page instead of the current one. There are 2 types of redirects, a 302 redirect which is considered temporary, and a 301 redirect which is considered permanent. The only difference between them is that the browser can cache and remember the 302 redirects so that […]

October 19, 2021 in Code examples
Deven
Deven wrote

Mongoose UpdateOne() example

There are various methods available in mongoose to update the document like .save(), findOneAndUpdate(), updateOne(). Each method has it’s own benefits. In today’s post, we are going to use updateOne() & see what is the main difference between update & update one method. updateOne(): There are multiple documents saved inside MongoDB which match the criteria […]

October 19, 2021 in Code examples