Showing posts from July, 2020

Node.js: Downloading a xml file from given url and reading its data elements.

In this article, we will see how we can download an XML file from a given URL and then access its elements. This can be used in many cases, for example, scraping data from a site which has data in the XML file or multiple files. The article is pretty short and most of it is just self-explanatory code. Also nowadays, you can get a lot of freelance jobs in data scrapping as data is the new oil today so this might be helpful. So let's begin with the code, var fs = require('fs') var https = require('https');//For accessing https url we need this module instead of http. var xml2js = require('xml2js');//Required for xml parsing. var file_name = 'data.xml'//This will be the name of file we will be generating. var DOWNLOAD_DIR =__dirname+'/'; //This function reads data from URL and writes data into new file //with respect to the given name and directory path. function download(){  var file_url='

2 JavaScript Interview Questions that you must know.

In this article, we will see in detail a couple of interview questions in Javascript. 1)What is a deep copy and Shallow copy? Shallow copy:  In shallow copy, all the top-level primitives get a copy excluding objects which are still connected to the original value. Note: If the array is of strings or number it gets copied but in case of an array of objects it is still connected to the original value. Primitive data types include the following: Number — e.g. 1 String — e.g. 'Hello' Boolean — e.g. true undefined null Example: var tshirt={     size:170,     sizeInLocal:'L',     sizeAvailable:{     'm':"Available"      } } Lets make a copy a shallow copy of tshirt object: var tshirt1=Object.assign({}, tshirt) tshirt1.sizeAvailable.m="NotAvailable"//Here tshirt.sizeAvailable.m will also become NotAvailable . tshirt1.size=150;//Only value of tshirt1.size is changed and not tshirt.size as size is of primitive type.  

4 html interview questions that you must know.

In this article, we will see some HTML interview questions I faced during interviews. So let's start, 1)What is Doctype in html? All HTML documents must start with a <!DOCTYPE> declaration. The declaration is not an HTML tag. It is an "information" to the browser about what document type to expect. In HTML 5, the declaration is simple: <!DOCTYPE html> Note: The <!DOCTYPE> declaration is NOT case sensitive. 2)What is DOM in html? The DOM (Document Object Model)is a W3C (World Wide Web Consortium) standard. The DOM defines a standard for accessing documents: The HTML DOM is a standard object model and programming interface for HTML. When a web page is loaded, the browser creates a Document Object Model of the page. It defines: The HTML elements as objects The properties of all HTML elements The methods to access all HTML elements The events for all HTML elements In other words: The HTML DOM is a standard for how to get, chan