You are on page 1of 10

DOM:

The Document Object Model (DOM) is a programming


interface for HTML and XML(Extensible markup language) documents. It defines the logical
structure of documents and the way a document is accessed and manipulated.
DOM is a way to represent the webpage in the structured hierarchical way so that it will become
easier for programmers and users to glide through the document. With DOM, we can easily
access and manipulate tags, IDs, classes, Attributes or Elements using commands or methods
provided by Document object.
DOM can be thought of as Tree or Forest(more than one tree). The term structure model is
sometimes used to describe the tree-like representation of a document. One important property of
DOM structure models is structural isomorphism: if any two DOM implementations are used to
create a representation of the same document, they will create the same structure model, with
precisely the same objects and relationships.
Properties of DOM:
The properties of document object that can be accessed and modified by the document object are
given below

Window Object: Window Object is at always at top of hierarchy.


Document object: When HTML document is loaded into a window, it becomes a document
object.
Form Object: It is represented by form tags.
Link Objects: It is represented by link tags.
Anchor Objects: It is represented by a href tags.
Form Control Elements:: Form can have many control elements such as text fields, buttons, radio
buttons, and checkboxes, etc.
Methods of Document Object:
write(“string”): writes the given string on the document.
getElementById(): returns the element having the given id value.
getElementsByName(): returns all the elements having the given name value.
getElementsByTagName(): returns all the elements having the given tag name.
getElementsByClassName(): returns all the elements having the given class name.

Distributed file systems:


A distributed file system (DFS) is a file system with data stored on a server. The data is accessed
and processed as if it was stored on the local client machine. The DFS makes it convenient to
share information and files among users on a network in a controlled and authorized way. The
server allows the client users to share files and store data just like they are storing the
information locally. However, the servers have full control over the data and give access control
to the clients.
One process involved in implementing the DFS is giving access control and storage management
controls to the client system in a centralized way, managed by the servers. Transparency is one of
the core processes in DFS, so files are accessed, stored, and managed on the local client
machines while the process itself is actually held on the servers. This transparency brings
convenience to the end user on a client machine because the network file system efficiently
manages all the processes. Generally, a DFS is used in a LAN, but it can be used in a WAN or
over the Internet.

A DFS allows efficient and well-managed data and storage sharing options on a network
compared to other options. Another option for users in network-based computing is a shared disk
file system. A shared disk file system puts the access control on the client’s systems so the data is
inaccessible when the client system goes offline. DFS is fault-tolerant and the data is accessible
even if some of the network nodes are offline. A DFS makes it possible to restrict access to the
file system depending on access lists or capabilities on both the servers and the clients,
depending on how the protocol is designed.
In addition to the functions of the file system of a single-processor system, the distributed file
system supports the following:

1. Remote information sharing


Any node, irrespective of the physical location of the file, can access the file.

2. User mobility
User should be permitted to work on different nodes.

3. Availability
For better fault-tolerance, files should be available for use even in the event of temporary failure
of one or more nodes of the system. Thus the system should maintain multiple copies of the files,
the existence of which should be transparent to the user.

4. Diskless workstations
A distributed file system, with its transparent remote-file accessing capability, allows the use of
diskless workstations in a system.

Arrays:
An array is a special variable, which can hold more than one value at a time.
If you have a list of items (a list of car names, for example), storing the cars in single variables
could look like this:
var car1 = "Saab";
var car2 = "Volvo";
var car3 = "BMW";
An array can hold many values under a single name, and you can access the values by referring
to an index number.
Using an array literal is the easiest way to create a JavaScript Array.
Syntax:
var array_name = [item1, item2, ...];
ex: var cars = ["Saab", "Volvo", "BMW"];
JavaScript arrays come in different forms and this post will explain what the difference is
between each array type. This post will look at the following array types;
Homogeneous arrays
Heterogeneous arrays
Multidimensional arrays
Jagged arrays
Homogeneous Arrays
As the name may suggest a homogeneous array is an array that stores a single data type(string,
int or Boolean values).
var array = ["Matthew", "Simon", "Luke"];
var array = [27, 24, 30];
var array = [true, false, true];
Heterogeneous Arrays
A heterogeneous array is the opposite to a homogeneous array. Meaning it can store mixed data
types.
var array = ["Matthew", 27, true];
Multidimensional Arrays
Also known as an array of arrays, multidimensional arrays allow you to store arrays within
arrays, a kind of “array-ception”.
var array = [["Matthew", "27"], ["Simon", "24"], ["Luke", "30"]];
Jagged Arrays
Jagged arrays are similar to multidimensional array with the exception being that a jagged array
does not require a uniform set of data.
var array = [
["Matthew", "27", "Developer"],
["Simon", "24"],
["Luke"]
];
as you can see, each array within the overall array is not equal, the first array has three items
stored in it, while the second has two and the third has just one.

Strings:
A JavaScript string is zero or more characters written inside quotes.
Example
var x = "John Doe";
either single quotes or double quotes can be used to form a string. A single quote can also be part
of a string.
var answer = "It's alright";
String Methods and Properties
Primitive values, like "John Doe", cannot have properties or methods (because they are not
objects).
But with JavaScript, methods and properties are also available to primitive values, because
JavaScript treats primitive values as objects when executing methods and properties.

String Length
The length property returns the length of a string:
Example
var txt= "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var sln = txt.length;
Finding a String in a String
The indexOf() method returns the index of (the position of) the first occurrence of a specified
text in a string:
Example
var str= "Please locate where 'locate' occurs!";
var pos = str.indexOf("locate");
The lastIndexOf() method returns the index of the last occurrence of a specified text in a string:
Example
var str = "Please locate where 'locate' occurs!";
var pos = str.lastIndexOf("locate");
Both indexOf(), and lastIndexOf() return -1 if the text is not found.
Searching for a String in a String
The search() method searches a string for a specified value and returns the position of the match:
Example
var str = "Please locate where 'locate' occurs!";
var pos = str.search("locate");
Extracting String Parts
There are 3 methods for extracting a part of a string:
slice(start, end)
substring(start, end)
substr(start, length)

The slice() Method


slice() extracts a part of a string and returns the extracted part in a new string.
The method takes 2 parameters: the starting index (position), and the ending index (position).
This example slices out a portion of a string from position 7 to position 13:
Example
var str = "Apple, Banana, Kiwi";
var res = str.slice(7, 13);
The result of res will be:
Banana
The substring() Method
substring() is similar to slice().
The difference is that substring() cannot accept negative indexes.
Example
var str = "Apple, Banana, Kiwi";
var res = str.substring(7, 13);
The result of res will be:
Banana
The substr() Method
substr() is similar to slice().
The difference is that the second parameter specifies the length of the extracted part.
Example
var str = "Apple, Banana, Kiwi";
var res = str.substr(7, 6);
The result of res will be:
Banana
Replacing String Content
The replace() method replaces a specified value with another value in a string:
Example
str = "Please visit Microsoft!";
var n = str.replace("Microsoft", "W3Schools");
Converting to Upper and Lower Case
A string is converted to upper case with toUpperCase():
Example
var text1 = "Hello World!"; // String
var text2 = text1.toUpperCase(); // text2 is text1 converted to upper
A string is converted to lower case with toLowerCase():
Example
var text1 = "Hello World!"; // String
var text2 = text1.toLowerCase(); // text2 is text1 converted to lower
The concat() Method
concat() joins two or more strings:
Example
var text1 = "Hello";
var text2 = "World";
var text3 = text1.concat(" ", text2);
String.trim()
String.trim() removes whitespace from both sides of a string.
Example
var str =" Hello World! ";
alert(str.trim());
Extracting String Characters
There are 3 methods for extracting string characters:
charAt(position)
charCodeAt(position)
Property access [ ]

The charAt() Method


The charAt() method returns the character at a specified index (position) in a string:
Example
var str = "HELLO WORLD";
str.charAt(0); // returns H
The charCodeAt() Method
The charCodeAt() method returns the unicode of the character at a specified index in a string:
The method returns a UTF-16 code (an integer between 0 and 65535).
Example
var str = "HELLO WORLD";

str.charCodeAt(0); // returns 72

CSS:
Cascading Style Sheet(CSS) is used to set the style in web pages which contain HTML elements.
It sets the background color, font-size, font-family, color, … etc property of elements in a web
pages.
There are three types of CSS which are given below:
Inline CSS
Internal or Embedded CSS
External CSS
Inline CSS: Inline CSS contains the CSS property in the body section attached with element is
known as inline CSS. This kind of style is specified within an HTML tag using style attribute.
<!DOCTYPE html>
<html>
<head>
<title>Inline CSS</title>
</head>

<body>
<p style = "color:#009900;
font-size:50px;
font-style:italic;
text-align:center;">
GeeksForGeeks</p>
</body>
</html>
Internal or Embedded CSS: This can be used when a single HTML document must be styled
uniquely. The CSS rule set should be within the HTML file in the head section i.e the CSS is
embedded within the HTML file.
<!DOCTYPE html>
<html>
<head>
<title>Internal CSS</title>
<style>
.main {
text-align:center;
}
.GFG {
color:#009900;
font-size:50px;
font-weight:bold;
}
.geeks {
font-style:bold;
font-size:20px;
}
</style>
</head>
<body>
<div class = "main">
<div class ="GFG">GeeksForGeeks</div>
<div class ="geeks">A computer science portal for geeks</p>
</div>
</body>
</html>

External CSS: External CSS contains separate CSS file which contains only style property with
the help of tag attributes (For example class, id, heading, … etc). CSS property written in a
separate file with .css extension and should be linked to the HTML document using link tag. This
means that for each element, style can be set only once and that will be applied across web
pages.
The file given below contains CSS property. This file save with .css extension. For Ex: geeks.css
body {
background-color:powderblue;
}
.main {
text-align:center;
}
.GFG {
color:#009900;
font-size:50px;
font-weight:bold;
}
#geeks {
font-style:bold;
font-size:20px;
}
Below is the HTML file that is making use of the created external style sheet
link tag is used to link the external style sheet with the html webpage.
href attribute is used to specify the location of the external style sheet file.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="geeks.css"/>
</head>
<body>
<div class = "main">
<div class ="GFG">GeeksForGeeks</div>
<div id ="geeks">A computer science portal for geeks</p>
</div>
</body>
</html>
Properties of CSS: Inline CSS has the highest priority, then comes Internal/Embedded followed
by External CSS which has the least priority. Multiple style sheets can be defined on one page. If
for an HTML tag, styles are defined in multiple style sheets then the below order will be
followed.
As Inline has the highest priority, any styles that are defined in the internal and external style
sheets are overridden by Inline styles.
Internal or Embedded stands second in the priority list and overrides the styles in the external
style sheet.
External style sheets have the least priority. If there are no styles defined either in inline or
internal style sheet then external style sheet rules are applied for the HTML tags.

Regular Expressions:
Regular expressions are another type of data in JavaScript, used to search and match strings to
identify if a string is a valid domain name or to replace all instances of a word within a string, for
example.
Regular expressions have their own syntax and often you’ll need to consult a regular expression
reference if you’re doing something complex. Just search the Internet for what you need!
The following is a very high-level overview of a complex area, going through some simple
examples to show how to do it in JavaScript.
Creating regular expressions
Like with objects and arrays, there is a regular expression literalsyntax designated by two
forward slashes. Everything between is the expression:

var regex = /^[a-z\s]+$/;


This expression matches strings that are made of lowercase letters and whitespace from
beginning to end. The caret (“^”) indicates the start of the string, and the brackets indicate that
anything between the opening and closing brace - letter a to z (“a-z”), lowercase, and white-
space, indicated by the special “\s” character - can be repeated one or more times up to the end of
the string, indicated by the dollar (“$”) symbol.
Strings have a few useful methods that accept regular expressions; here’s a look
at match and replace:

var lowerCaseString = 'some characters';

if (lowerCaseString.match(regex)) {
alert('Yes, all lowercase');
}
match produces a truthy value if the regular expression matches the string
(lowerCaseString) match is called on. The string matches, so execution drops into
the if statement to show an alert.
Regular expressions can also be used to replace text:
var text = "There is everything and nothing.";

text = text.replace(/(every|no)thing/g, 'something');

// text is now "something and something"


This expression matches the word “everything” and the word “nothing” and replaces all
occurrences of them with the word “something”. Notice the “g” after the closing forward slash
(“/”) of the regular expression - this is the global flag that means the expression should
match all occurrences, rather than just the first, which is what it does by default.
Flags always go after the closing slash. The other flag you might need to use is the case-
insensitive flag. By default, regular expressions care about the difference between uppercase and
lowercase letters, but this can be changed using the “i” flag.
var text = "Everything and nothing.";

text = text.replace(/(every|no)thing/gi, "something");

// text is now "something and something"

Boot strapping:
A bootstrap is the program that initializes the operating system (OS) during startup. The term
bootstrap or bootstrapping originated in the early 1950s. It referred to a bootstrap load button that
was used to initiate a hardwired bootstrap program, or smaller program that executed a larger
program such as the OS. The term was said to be derived from the expression “pulling yourself
up by your own bootstraps,” starting small and loading programs one at a time while each
program is “laced” or connected to the next program to be executed in sequence.
Bootstrapping is the process of loading a set of instructions when a computer is first turned on or
booted. During the startup process, diagnostic tests are performed, such as the power-on self-test
(POST), that set or check configurations for devices and implement routine testing for the
connection of peripherals, hardware and external memory devices. The bootloader or bootstrap
program is then loaded to initialize the OS.
Typical programs that load the OS are:
GNU Grand Unified Bootloader (GRUB): A multiboot specification that allows the user to
choose one of several OSs
NT Loader (NTLDR): A bootloader for Microsoft’s Windows NT OS that usually runs from the
hard drive
Linux Loader (LILO): A bootloader for Linux that generally runs from a hard drive or floppy
disc
Network Interface Controller (NIC): Uses a bootloader that supports booting from a network
interface such as Etherboot or pre-boot execution environment (PXE)
Prior to bootstrapping a computer is said to start with a blank main memory. The bootstrap
allows the sequence of programs to load in order to initiate the OS. The OS is the main program
that manages all programs that run on a computer and performs tasks such as controlling
peripheral devices like a disc drive, managing directories and files, transmitting output signals to
a monitor and identifying input signals from a keyboard.
Bootstrap can also refer to preparing early programming environments incrementally to create
more complex and user-friendly programming environments. For example, at one time the
programming environment might have consisted of an assembler program and a simple text
editor. Over time, gradual improvements have led to today's sophisticated object-oriented
programming languages and graphical integrated development environments (IDEs).

You might also like