Full Stacks Answers
Full Stacks Answers
HTML (HyperText Markup Language) is the standard language for creating web
pages. It describes the structure of web pages using markup. Markup in HTML is the
process of adding tags to text to define its structure and appearance. Tags like <p>,
<a>, and <div> are used to define paragraphs, links, and divisions respectively.
3. Explain DOM? Why is it important to know about DOM for developing web
applications?
The DOM (Document Object Model) is a programming interface for web documents.
It represents the page so that programs can change the document structure, style, and
content. Knowing about the DOM is crucial for web development as it allows
developers to interact with and manipulate HTML and XML documents dynamically,
enabling the creation of interactive and dynamic web applications.
5. What do you mean by full stack? Explain the technologies involved in building a
general full stack app.
Full stack development refers to the development of both the front-end (client-side)
and back-end (server-side) parts of a web application. Technologies involved include:
o Front-end: HTML, CSS, JavaScript, frameworks like React, Angular, or
Vue.js.
o Back-end: Server, database, and application, typically using technologies like
Node.js, Express.js, Python (Django, Flask), Ruby on Rails, databases like
MongoDB, MySQL, or PostgreSQL.
6. Explain the different versions of HTML, CSS, and JS on the basis of advantages and
disadvantages.
HTML:
o HTML4: Introduction of forms, tables, and improved support for scripting.
o HTML5: New elements like <header>, <footer>, <article>, multimedia
support, and improved accessibility.
CSS:
o CSS2: Added support for media types and improved positioning.
o CSS3: Modularized CSS, added support for animations, transitions, and
responsive design.
JS:
o ES5 (ECMAScript 5): Standardized JSON, added new array methods.
o ES6 (ECMAScript 2015): Introduced let, const, arrow functions, classes, and
modules.
8. What are the different frameworks for JS available for developing backend?
9. What are the different JS frameworks available for developing front end?
10. What are the different CSS frameworks available for designing the front end?
async and await are used to handle asynchronous operations in JavaScript. They
allow writing asynchronous code in a synchronous manner.
try {
console.log(data);
} catch (error) {
console.error('Error:', error);
fetchData();
callback();
function sayGoodbye() {
console.log('Goodbye!');
greet('Alice', sayGoodbye);
14. What are media queries in CSS? Explain with examples to implement media queries
in smartphone, laptop, tablets.
Media queries are used in CSS to apply styles based on the conditions of the device
(like screen size). Example:
/* Smartphones */
@media (max-width: 600px) {
body {
background-color: lightblue;
}
}
/* Tablets */
@media (min-width: 601px) and (max-width: 992px) {
body {
background-color: lightgreen;
}
}
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.m
in.css">
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min
.js"></script>
<table border="1">
<tr>
<td>Main Table Cell 1</td>
<td>
<table border="1">
<tr>
<td>Nested Table Cell 1</td>
<td>Nested Table Cell 2</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>Main Table Cell 2</td>
<td>Main Table Cell 3</td>
</tr>
</table>
18. Write a program in JavaScript to demonstrate the use of alert and prompt.
20. Can form validation be done just by using HTML? If yes, explain with examples.
Yes, HTML5 provides built-in form validation features using attributes like
required, pattern, minlength, maxlength, type, and title.
<form>
<input type="text" required pattern="[A-Za-z]{3,}" title="Only
letters and at least 3 characters long">
<input type="submit">
</form>
22.Mention the different types of selectors in CSS and differentiate between them?
Type Selector: Selects elements by tag name.
p {
color: blue;
}
.example {
color: red;
}
#example {
color: green;
}
[type="text"] {
border: 1px solid black;
}
a:hover {
color: orange;
}
p::first-line {
font-weight: bold;
}
23. What is body parser and how do we use body parser get data from?
javascript
Copy code
const bodyParser = require('body-parser');
const express = require('express');
const app = express();
app.use(bodyParser.json());
app.post('/data', (req, res) => {
console.log(req.body);
res.send('Data received');
});
app.listen(3000, () => console.log('Server running on port
3000'));
o A responsive website adapts its layout and design based on the screen size and
orientation of the device being used to view it. In Chrome, you can check
responsiveness using Developer Tools:
1. Right-click on the webpage and select "Inspect" or press
Ctrl+Shift+I.
2. Click on the "Toggle device toolbar" icon or press Ctrl+Shift+M.
3. You can now switch between different device views to see how the
website adapts.
o GET:
o POST:
o Meta tags provide metadata about the HTML document. They are placed
inside the <head> tag.
html
Copy code
<meta charset="UTF-8"> <!-- Specifies the character encoding
for the HTML document -->
<meta name="description" content="Free Web tutorials"> <!--
Description of the webpage -->
<meta name="keywords" content="HTML, CSS, JavaScript"> <!--
Keywords for search engines -->
<meta name="author" content="John Doe"> <!-- Author of the
document -->
<meta name="viewport" content="width=device-width, initial-
scale=1.0"> <!-- Responsive design settings -->
javascript
Copy code
let x = 10;
console.log('The value of x is:', x); // Output: The value of x
is: 10
o <div>:
A block-level element that starts on a new line and takes up the full
width available.
Used to group block-level content.
o <span>:
An inline element that does not start on a new line and only takes up as
much width as necessary.
Used to group inline content.
o The <!DOCTYPE html> declaration defines the document type and version of
HTML being used. It ensures that the browser renders the page in standards
mode rather than quirks mode, which can prevent inconsistencies across
different browsers.
30.We have heard about tr and td in HTML tables. What is th? And how is it
different from tr?
o <th> defines a header cell in a table and is used inside <tr>. It makes the
content bold and centered by default.
o <tr> defines a row in a table.
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
31.Differentiate between ordered and unordered list? How do I change the ordering
and unordering style in the list? E.g., disk to diamond or start from 3rd or 4th
number.
html
Copy code
<ol start="3" type="I">
<li>Item 1</li>
<li>Item 2</li>
</ol>
<ul style="list-style-type: square;">
<li>Item 1</li>
<li>Item 2</li>
</ul>
nodemon app.js
o Difference:
36. How do you tell the Node server to run on any port that is available or to run on
a specific code?
app.listen(port, () => {
console.log(`Server running on port ${port}`);
});
// Array Destructuring
const [a, b] = [1, 2];
console.log(a); // Output: 1
console.log(b); // Output: 2
// Object Destructuring
const {name, age} = {name: 'John', age: 30};
console.log(name); // Output: John
console.log(age); // Output: 30
41. Write a program in JS to filter out the even numbers from an array.
43. What are promises in JavaScript? Write a program to demonstrate the use of
promises.
o Promises in JavaScript represent the eventual completion (or failure) of an
asynchronous operation and its resulting value.
myPromise.then((message) => {
console.log(message); // Output after 2 seconds: Promise
fulfilled!
}).catch((error) => {
console.error(error);
});
44. What is the purpose of using async/await?
o async/await is syntactic sugar built on top of promises, making
asynchronous code easier to write and read. async declares an asynchronous
function, and await pauses the execution until the promise resolves.
fetchData();
fetch('https://api.example.com/data')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
46. What are the different types of storage available in the browser? Explain with
examples.
o Local Storage: Stores data with no expiration time. Data is available even
after the browser is closed and reopened.
localStorage.setItem('name', 'John');
console.log(localStorage.getItem('name')); // Output: John
o Session Storage: Stores data for the duration of the page session. Data is
cleared when the page session ends.
sessionStorage.setItem('name', 'Doe');
console.log(sessionStorage.getItem('name')); // Output: Doe
o Cookies: Store data that is sent to the server with every HTTP request. Can
have an expiration date.
// Middleware function
app.use((req, res, next) => {
console.log('Request URL:', req.originalUrl);
next();
});
app.use(cors());
{
"name": "my-app",
"version": "1.0.0",
"description": "A sample Node.js project",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"author": "John Doe",
"license": "ISC",
"dependencies": {
"express": "^4.17.1"
}
}