Modular programming is the process of subdividing a computer program into separate sub-programs can often be used in a variety of applications and functions with other components of the system.
Less code has to be written, its simple and easy to understand.
A single procedure can be developed for reuse, eliminating the need to retype the code many times.
Programs can be designed more easily because a small team deals with only a small part of the entire code.
Enables multiple programmers to divide up the work and debug pieces of the program independently.
Enforce logical boundaries between components and improve maintainability (every modular application has a version number associated with it).
Make a testable code as it mimimize the dependency between the units.
Errors can easily be identified, as they are localized to a subroutine or function.
Teams can develop modules separately and do not require knowledge of all modules in the system.
The same code can be used in many applications.
The scoping of variables can easily be controlled.
Even if you define a global variable in a module using var, let or const keywords, the variables are scoped locally to the module rather than being scoped globally. This happens because each module has a function wrapper of its own and the code written inside one function is local to that function and cannot be accessed outside this function.
The module parameter (rather a keyword in a module in Node) refers to the object representing the current module. exports is a key of the module object, the corresponding value of which is an object. The default value of module.exports object is {} (empty object). You can check this by logging the value of module keyword inside any module.
module.exports['key'] = nameOfTheFunction;
or Adding all of them at once by using object:
module.exports={ firstFunc:FirstFunction, secondFun:SecondFunction }
require keyword refers to a function which is used to import all the constructs exported using the module.exports object from another module.
-The value returned by the require function in module y is equal to the module.exports object in the module x.
const variableToHoldExportedStuff = require('idOrPathOfModule');
-What do you think will happen if I try to access the variable named PI defined in module A inside module B without exporting it from module A?
pi = undefined
*So, you may be wondering why you didn’t get a ReferenceError. This is because you are trying to access a key named PI inside the module.exports object returned by the require function. You also know that the key named PI does not exist in the module.exports object.
Note that when you try to access a non-existent key in an object, you get the result as undefined. This is the reason why you get PI as undefined instead of getting a ReferenceError.
3- Update files :
fs.appendFile),(fs.writeFile())
4- Delete files :
fs.unlink()
5- Rename files
fs.rename
var filename = path.basename('/Users/Refsnes/demo_path.js');
var filename = path.basename('/Users/Refsnes/demo_path.js', 'js');
var directories = path.dirname('/Users/Refsnes/demo_path.js');
var ext = path.extname('/Users/Refsnes/demo_path.js');
A URL - Uniform Resource Locator - more commonly known as a "web address".
A URL is human-readable text that was designed to replace the numbers (IP addresses) that computers use to communicate with servers. They also identify the file structure on the given website. A URL consists of a protocol, domain name, and path (which includes the specific subfolder structure where a page is located) and has the following basic format:
The protocol indicates how a browser should retrieve information about a resource. The web standard is http:// or https:// (the "s" stands for "secure"), but it may also include things like mailto: (to open your default mail client) or ftp: (to handle file transfers).
The domain name (or hostname): is the human-readable name of the specific location where a resource (in most cases, a website) is located.
top-level domain (TLD) as something of a category for websites. While you're likely familiar with .com, there is also .edu for educational sites, .gov for governmental sites, and many, many more.
URLs also contain things like the specific folders and/or subfolders that are on a given website, any parameters (like click tracking or session IDs) that might be stored in the URL, and anchors that allow visitors to jump to a specific point in the resource.
URL is a namespace used to host 2 static methods used to manipulate URLs using Blobs:
URL.createObjectURL():
static method creates a DOMString containing a URL representing the object given in the parameter. The URL lifetime is tied to the document in the window on which it was created. The new object URL represents the specified File object or Blob object.
Syntax :
Parameters :
object:
A File, Blob or MediaSource object to create an object URL for.
Return value :
DOMString -UTF-16 String-
URL.revokeObjectURL() :
static method releases an existing object URL which was previously created by calling URL.createObjectURL(). Call this method when you've finished using an object URL to let the browser know not to keep the reference to the file any longer.
Syntax :
Parameters :
objectURL : A DOMString
Return value :
Void
Query string in URL is very useful to work with dynamic content. Generally, server-side language is used to get query string from URL. But you can also get query string parameters from URL to client-side. The query string parameters and values can be easily retrieved from the URL using JavaScript.
Assume URL is :
Get Query String Parameters :
Use location.search to get query string parameters including the question mark (?).
Get Query String Parameter Value :
One of the reasons these links aren’t validating is because they contain non-encoded ampersand ( & ) characters. Ampersands are often used in URL query strings to demarcate granular chunks of information, for example:
To get this code to validate, we need to encode the ampersands with &, for example:
Replacing the ampersand characters with encoded equivalents does not change the functionality of the query string, but it does produce completely valid code.
a blank space is equivalent to “%20”