Programming Articles - Page 2291 of 3366

Convert Image to Data URI with JavaScript

Abdul Rawoof
Updated on 26-Aug-2022 11:53:41

12K+ Views

JavaScript has a convention for converting an image URL or a local PC image to a base64 string. This string can contain a variety of symbols and letters. In here it is explained how to make a canvas element, load an image into it, and use toDataURL() to display the string representation. To obtain the base64 string representation, we will also use the file reader option. In this case, a canvas element will be created and its dimensions will be specified. The dataURL where the string representation will be stored. We will add random images from online sources and ensure ... Read More

How to check if element exists in the visible DOM?

Ayush Gupta
Updated on 27-Nov-2019 10:42:43

761 Views

We can use the Node.contains method to do this check. The Node.contains() method returns a Boolean value indicating whether a node is a descendant of a given node, i.e. the node itself, one of its direct children (childNodes), one of the children's direct children, and so on.ExampleFor example, you are looking for an element with id test, you can use the following −const elem = document.querySelector('#test'); console.log(document.body.contains(elem));This will log true or false based on whether the element is present in the visible DOM.

The Pros and Cons of Using Ajax

Ayush Gupta
Updated on 27-Nov-2019 10:35:33

6K+ Views

Ajax is a set of web development techniques using many web technologies on the client-side to create asynchronous web applications. With Ajax, web applications can send and retrieve data from a server asynchronously without interfering with the display and behavior of the existing page.Any other technology Ajax also has its own pros and cons. Let's look at some of those.Pros −Allows applications to render without data and fill data as the application gets it from the server.Gives platform independence to application developersFaster page rendersMore responsive applicationsNo rerenders of whole pages are needed to update only a single area.Cons−Any user whose ... Read More

How to Send and Receive JSON Data to and from the Server

Ayush Gupta
Updated on 27-Nov-2019 10:20:22

3K+ Views

JavaScript can send network requests to the server and load JSON. JS does this using something called AJAX. AJAX stands for Asynchronous JavaScript and XML. JS has an API, fetch, to GET(receive) and POST(send) information to the server.You can use fetch to GET JSON data in the following way −Exampleconst URL = 'https://jsonplaceholder.typicode.com/todos/1' // Send a GET request without any data to the server fetch(URL, {method: "GET"}) // Get the JSON data from the raw response    .then(res => res.json()) // Print the result    .then(console.log)OutputThis will give the output −{    "userId": 1,    "id": 1,    "title": "delectus ... Read More

How to do string interpolation in JavaScript?

Abdul Rawoof
Updated on 26-Aug-2022 11:56:24

18K+ Views

String interpolation in JavaScript is a process in which an expression is inserted or placed in the string. To insert or embed this expression into the string a template literal is used. By using string interpolation in JavaScript, values like variables and mathematical expressions and calculations can also be added. The template literal has a dollar sign followed by curly brackets. Inside the curly brackets of this template literal, the expression or the mathematical calculation which is to evaluated and embedded should be written. Syntax The syntax of the string interpolation in JavaScript is as follows. `string where interpolation should ... Read More

Advantages and Disadvantages of JavaScript

Abdul Rawoof
Updated on 12-Sep-2023 01:20:55

31K+ Views

JavaScript might be a client-side scripting language, inferring that the client's browser handles ASCII text file processing rather than an online server. With the aid of JavaScript, this can load the webpage without contacting the primary server. For instance, a JavaScript function might verify that all the required fields are filled out on an online form before it is submitted. The JavaScript code has the ability to output an error message before any data is actually sent to the server. Both advantages and disadvantages apply to JavaScript. A client's browser is frequently used to execute JavaScript directly. Similar advantages to ... Read More

Difference between FTP and TFTP

Kiran Kumar Panigrahi
Updated on 22-Aug-2022 13:57:02

5K+ Views

FTP is used for copying files from one host to another host location. FTP works on Port 20 and 21. Port 20 is used for data and Port 21 is used for connection control.TFTP is lighter than FTP and is used when a file transfer functionality is needed without FTP features. It works on Port 69 and follows the UDP protocol.Read through this article to find out more about FTP and TFTP and how they are different from each other.What is FTP?FTP stands for File Transfer Protocol. It is a client/server protocol for sending files to and from a host ... Read More

Difference Between Go and Python Programming Language

Kiran Kumar Panigrahi
Updated on 28-Jul-2022 12:34:26

444 Views

Python debuted in 1991. Google released Golang in 2012. Google's programmers built Golang to expedite development and improve other languages. Golang has stricter grammar and layout than Python.Golang allows multitasking, use of channels, goroutines, etc. Golang can be used in networking, cloud, and server-side projects. Golang can automate DevOps and site reliability. Microcontrollers, games, and robots are programmed in Golang. Golang powers Kubernetes, Prometheus, and Docker.Python is an object oriented programming language designed by Guido van Rossum in 1991 and is maintained by Python Software Foundation. Python was developed to keep language readability easy and to quickly integrate with other ... Read More

Differences between Difference between getc(), getchar(), getch() and getche() functions

Mahesh Parahar
Updated on 26-Nov-2019 10:42:58

1K+ Views

All of these functions are used to get character from input and each function returns an integer signifying the status code as well.Following are the important differences between getc(), getchar(), getch() and getche() functions.getc()getc() can read characters from any stream. Returns EOF on failure.Syntaxint getc(FILE *stream);getchar()getchar() can read characters from standard input only.Syntaxint getchar();getch()getch() can read characters from standard input but it does not use any buffer and returns immidately without waiting for enter key pressed.Syntaxint getch();getche()getche() behaves similar to getch() as it can read characters from standard input and it does not use any buffer and returns immidately without ... Read More

Differences between Interface and class in Java

Mahesh Parahar
Updated on 07-Dec-2023 11:54:40

25K+ Views

Class A class is a blueprint from which individual objects are created. A class can contain any of the following variable types. Local Variables − Variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and the variable will be destroyed when the method has completed. Instance Variables − Instance variables are variables within a class but outside any method. These variables are initialized when the class is instantiated. Instance variables can be accessed from inside any method, constructor or blocks of that particular class. Class Variables − Class variables are variables declared ... Read More

Advertisements