Final Exam Flashcards

1
Q

Explain What is DevOps?

A

DevOps is a newly emerging term in the IT field, which is nothing but a practice that emphasizes the collaboration and communication of both software developers and other information technology (IT) professionals. It focuses on delivering software products faster and lowering the failure rate of releases.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which software-development methodology would be best if an organization needed to develop a software tool for a small group of users in the marketing department? Why?

A

Rapid application development (RAD) is a software-development (or systems-development) methodology that focuses on quickly building a working model of the software. This methodology is much better suited for smaller projects than SDLC and has the added advantage of giving users the ability to provide feedback throughout the process.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Software Development: What is the difference between a library and a framework

A

A library provides a set of helper functions/objects/modules which your application code calls for specific functionality. Libraries typically focus on a narrow scope. A Framework has defined open or unimplemented functions or objects which the developer uses to create a custom application. Framework provides structure and it has a wider scope than a library.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is CORS?

A

CORS, abbreviation for Cross-Origin Resource Sharing, is a process used to gain the authority of different web resources on different domains. With the help of CORS, the integration of web scripts can be implemented more freely with the external content of the original domain.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a REST API?

A

Application programming interfaces (APIs) provide the platform and medium for applications to talk to and understand each other. APIs specify the way information passed across platforms is structured so that applications can exchange data and information.
REST is an API architecture style. It stands for representational state transfer. REST specifies how data is presented to a client in a format that is convenient for the client. Data exchanges happen either in JSON or XML format. However, many APIs today return JSON data.
The key elements of the REST API paradigm are
* a client or software that runs on a user’s computer or smartphone and initiates communication;
* a server that offers an API as a means of access to its data or features; and
* a resource, which is any piece of content that the server can provide to the client (for example, a video or a text file).
To get access to a resource, the client sends an HTTP request. In return, the server generates an HTTP response with encoded data on the resource. Both types of REST messages are self-descriptive, meaning they contain information on how to interpret and process them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the REST request structure?

A

Any REST request includes four essential parts: an HTTP method, an endpoint, headers, and a body.
An HTTP method describes what is to be done with a resource. There are four basic methods also named CRUD operations:
POST to Create a resource, GET to Retrieve a resource, PUT to Update a resource, and DELETE to Delete a resource. An endpoint contains a Uniform Resource Identifier (URI) indicating where and how to find the resource on the Internet. The most common type of URI is a Unique Resource Location (URL), serving as a complete web address.
Headers store information relevant to both the client and server. Mainly, headers provide authentication data — such as an API key, the name or IP address of the computer where the server is installed, and the information about the response format.
A body is used to convey additional information to the server. For instance, it may be a piece of data you want to add or replace.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Key differences between GET and POST?

A

GET request is simple and used to fetch a resource on the server (read). POST method is used so that resources are created on the server. POST request has a body.
Question. What are the latest trends in Full Stack Web Development?
Ans – The rise of Vue JS Functional, real-time web apps, progressive apps, and mobile web development. Programming benefits from JavaScript improvements The emergence of more compatible extensions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the latest trends in Full Stack Web Development?

A

The rise of Vue JS Functional, real-time web apps, progressive apps, and mobile web development. Programming benefits from JavaScript improvements The emergence of more compatible extensions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Describe front-end and backend in general terms

A

Frontend refers to the client-side of an application. Backend refers to the server-side of an application. Frontend is the part of a web application that users can see/view and interact with. Backend constitutes everything that happens behind the scenes. Frontend typically includes everything that attributes to the UI/visual aspects of a web application. Backend generally includes a (web) server that communicates with a DB to serve requests. HTML, CSS, JavaScript, are some of the essentials of frontend development. Java, PHP and, JavaScript are some of the backend development technologies.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What Is Node.js?

A

Node.js is an open-source, cross-platform, JavaScript runtime environment that executes JavaScript code outside of a web browser. Is is sometimes also referred to as a web framework.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Explain what is the NodeJS Event Loop.

A

NodeJS is single threaded. Event loop is an endless loop, which waits for tasks, executes them and then sleeps until it receives more tasks. The event loop executes tasks from a queue of events. Because of the event loop we can use callbacks and promises.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How can you share code between files in NodeJS?

A

This depends on the JavaScript environment.
On the server (Node.js) each file is treated as a module and it can export variables and functions by attaching them to the module.exports object. This follows CommonJS.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the most loved language of a full stack developer and why?

A

Full Stack Developers work with a multitude of languages. Ideally, a full-stack developer must have a few languages that he loves, preferably, some with which he can design the front end and others with which he can take care of the back end. A fullstack developer should be able to demonstrate that well and remember to include the basic most used ones like HTML, CSS, Python, JavaScript etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What’s the difference between Git and GitHub?

A

While Git is a tool that’s used to manage multiple versions of source code edits that are then transferred to files in a Git repository, GitHub serves as a location for uploading copies of a Git repository.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a Git repository?

A

Git repository refers to a place where all the Git files are stored. These files can either be stored on the local repository or on the remote repository. It tracks and saves the history of all changes made to the files in a Git project. It saves this data in a directory called .git, also known as the repository folder.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Name a few Git commands with their function

A

Git config - Configure the username and email address
Git add - Add one or more files to the staging area
Git diff - View the changes made to the file
Git init - Initialize an empty Git repository
Git commit - Commit changes to head but not to the remote repository

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What does the git push command do?

A

The Git push command is used to push the content in a local repository to a remote repository. After a local repository has been modified, a push is executed to share the modifications with remote team members.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What are some of the advantages of MongoDB?

A

MongoDB supports field, range-based, string pattern matching type queries for searching the data in the database
MongoDB support primary and secondary index on any fields
MongoDB basically uses JavaScript objects in place of procedures
MongoDB uses a dynamic database schema
MongoDB is very easy to scale up or down
MongoDB has inbuilt support for data partitioning (Sharding)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is a Document in MongoDB?

A

A Document in MongoDB is an ordered set of keys with associated values. It is represented by a map, hash, or dictionary. In JavaScript, documents are represented as objects: {“greeting” : “Hello world!”}
Complex documents will contain multiple key/value pairs: {“greeting” : “Hello world!”, “views” : 3}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is a Collection in MongoDB?

A

A collection in MongoDB is a group of documents. If a document is the MongoDB analog of a row in a relational database, then a collection can be thought of as the analog to a table. Documents within a single collection can have any number of different “shapes.”, i.e. collections have dynamic schemas. For example, both of the following documents could be stored in a single collection:
{“greeting” : “Hello world!”, “views”: 3} {“signoff”: “Good bye”}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What are Databases in MongoDB?

A

MongoDB groups collections into databases. MongoDB can host several databases, each grouping together collections. Some reserved database names are as follows:
admin
local
config

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is the MongoDB Shell?

A

The MongoDB Shell, mongosh, is a fully functional JavaScript and Node.js 14.x REPL environment for interacting with MongoDB deployments. You can use the MongoDB Shell to test queries and operations directly with your database.
You can use the mongo shell to query and update data as well as perform administrative operations.
To start the shell, run the mongosh executable:
$ mongosh
The MongoDB shell is a full-featured JavaScript interpreter, capable of running arbitrary JavaScript programs. Even basic math works on this:
> x = 100;
200
> x / 5;
20

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

How to add data in MongoDB?

A

The basic method for adding data to MongoDB is “inserts”. To insert a single document, use the collection’s insertOne method:
> db.books.insertOne({“title” : “Start With Why”})
For inserting multiple documents into a collection, we use insertMany. This method enables passing an array of documents to the database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

How to perform queries in MongoDB?

A

The find method is used to perform queries in MongoDB. Querying returns a subset of documents in a collection, from no documents at all to the entire collection. Which documents get returned is determined by the first argument to find, which is a document specifying the query criteria.
Example: > db.users.find({“age” : 24})

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What are the basic data types in MongoDB?

A

MongoDB supports a wide range of data types as values in documents. Documents in MongoDB are similar to objects in JavaScript. Along with JSON’s essential key/value–pair nature, MongoDB adds support for a number of additional data types.
The common data types in MongoDB are:-
Null {“x” : null}
Boolean {“x” : true}
Number {“x” : 4}
String {“x” : “foobar”}
Date {“x” : new Date()}
Regular expression {“x” : /foobar/i}
Array {“x” : [“a”, “b”, “c”]}
Embedded document {“x” : {“foo” : “bar”}}
Object ID {“x” : ObjectId()}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

When to use MongoDB?

A

You should use MongoDB when you are building internet and business applications that need to evolve quickly and scale elegantly. MongoDB is popular with developers of all kinds who are building scalable applications using agile methodologies. MongoDB is a great choice if one needs to:
Support a rapid iterative development.
Scale to high levels of read and write traffic - MongoDB supports horizontal scaling through Sharding, distributing data across several machines, and facilitating high throughput operations with large sets of data.
Scale your data repository to a massive size.
Evolve the type of deployment as the business changes.
Store, manage and search data with text, geospatial, or time-series dimensions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

When to use SQL vs NoSQL for your business?

A

Generally, NoSQL is preferred for:
Graph or hierarchical data
Data sets which are both large and mutate significantly,
Businesses growing extremely fast but lacking data schemata.
In terms of use cases, this might translate to social networks, online content management, streaming analytics, or mobile applications.
SQL is more appropriate when the data is:
Small
Conceptually modeled as tabular
In systems where consistency is critical.

28
Q

Describe the difference for SQL vs. NOSQL in terms of Language.

A

SQL has been around for over 40 years, so it is recognizable, documented, and widely-used. Safe and versatile, it’s particularly well suited for complex queries. However, SQL restricts the user to working within a predefined tabular schema, and more care must be taken to organize and understand the data before it is used.
The dynamic schemata of NoSQL databases allow representation of alternative structures, often alongside each other, encouraging greater flexibility. There is less emphasis on planning, greater freedom when adding new attributes or fields, and the possibility of varied syntax across databases. As a group, however, NoSQL languages lack the standard interface which SQL provides, so more complex queries can be difficult to execute.
Though there are many dialects of SQL, all share a common syntax and almost-identical grammar. When querying relational databases, fluency in one language translates to proficiency in most others. On the other hand, there is very little consistency between NoSQL languages, as they concern a diverse set of unrelated technologies. Many NoSQL databases have a unique data manipulation language constrained by particular structures and capabilities.

29
Q

Describe the difference for SQL vs. NOSQL in terms of Scalability.

A

Most SQL databases can be scaled vertically, by increasing the processing power of existing hardware. NoSQL databases use a master-slave architecture which scales better horizontally, with additional servers or nodes. These are useful generalizations, but it’s important to note:
SQL databases can be scaled horizontally as well, though sharding or partitioning logic is often the user’s onus and not well supported.
NoSQL technologies are diverse and while many rely on the master-slave architecture, options for scaling vertically also exist.
Savings made using more efficient data structures can overwhelm differences in scalability; most important is to understand the use case and plan accordingly.

30
Q

Describe the difference for SQL vs. NOSQL in terms of Structure.

A

SQL database schemata always represent relational, tabular data, with rules about consistency and integrity. They contain tables with columns (attributes) and rows (records), and keys have constrained logical relationships.

NoSQL databases need not stick to this format, but generally fit into one of four broad categories:

Column-oriented databases transpose row-oriented RDBMSs, allowing efficient storage of high-dimensional data and individual records with varying attributes.
Key-Value stores are dictionaries which access diverse objects with a key unique to each.
Document stores hold semi-structured data: objects which contain all of their own relevant information, and which can be completely different from each other.
Graph databases add the concept of relationships (direct links between objects) to documents, allowing rapid traversal of greatly connected data sets.

31
Q

Describe the difference for SQL vs. NOSQL in terms of Properties.

A

SQL databases must follow the “ACID” properties:
- Atomicity: transactions must either succeed completely or fail completely, even if there is a system failure.
- Consistency: the database must follow rules to prevent corruption and maintain its integrity.
- Isolation: concurrent transactions should not affect each other, and their final result should be the same as if they were run sequentially.
- Durability: successful transactions must be permanent, even if there is a system failure.

NoSQL databases follow the “CAP” theorem, which means they can only guarantee two out of three properties:
- Consistency: all requests receive the latest result or an error.
- Availability: all requests get a response, regardless of the result’s recency.
- Partition tolerance: the system can continue to operate despite delays or losses between nodes.

In summary, SQL databases ensure transactional integrity, while NoSQL databases prioritize scalability and availability.

32
Q

Describe the difference for SQL vs. NOSQL in terms of Support and communities.

A

SQL databases represent massive communities, stable codebases, and proven standards. Multitudes of examples are posted online and experts are available to support those new to programming relational data.
NoSQL technologies are being adopted quickly, but communities remain smaller and more fractured. However, many SQL languages are proprietary or associated with large single-vendors, while NoSQL communities benefit from open systems and concerted commitment to onboarding users.
SQL is available to most major platforms, from operating systems to architectures and programming languages. Compatibility varies more widely for NoSQL, and dependencies need to be investigated more carefully.

33
Q

What is mongoose in node js?

A

mongoose is an object modeling package for Node that essentially works like an ORM.

34
Q

Explain the difference between using mongoose and the native MongoDB driver/connector?

A

Mongoose provides a straight-forward, schema-based solution to model your application data. It includes built-in type casting, validation, query building, business logic hooks and more, out of the box. It is a Object Document Mapper or ODM. An Object Modelling Tool. However, if our collection contains documents with an uncertain schema, the MongoDB driver is the most straightforward alternative. It allows for more flexibility as one can directly interact with the database.

35
Q

Explain the difference between embedding and referencing (linking) for MongoDB data modeling.

A

Similarly to a relational database, MongoDB allows you to use schemas to define the fields and data types within your collections. One of the powerful schema options available in MongoDB is to relate documents to one another, either via embedding or referencing.
Embedded documents are stored as children inside a parent document. This means they are all stored under one collection, and whenever you retrieve the parent document, you also retrieve all its embedded documents.
Unlike embedded documents, referenced documents are stored in a separate collection to their parent document. Therefore, it’s possible to retrieve the parent document without retrieving any of its referenced documents. In storing the addresses of the child documents e.g. via a linked field using references.

36
Q

Which of the following is an embedded data model in MongoDB?
a) {
“_id”: 1,
“name”: “Ashley Peacock”,
“addresses”: [
{
“address_line_1”: “10 Downing Street”,
“address_line_2”: “Westminster”,
“city”: “London”,
“postal_code”: “SW1A 2AA”
},
{
“address_line_1”: “221B Baker Street”,
“address_line_2”: “Marylebone”,
“city”: “London”,
“postal_code”: “NW1 6XE”
}
]
}

b) // Stored in the user collection
{
“_id”: 1,
“name”: “Ashley Peacock”,
“addresses”: [
1000,
1001
]
}// Stored in the address collection
{
“_id”: 1000,
“address_line_1”: “10 Downing Street”,
“address_line_2”: “Westminster”,
“city”: “London”,
“postal_code”: “SW1A 2AA”
}// Stored in the address collection
{
“_id”: 1001,
“address_line_1”: “221B Baker Street”,
“address_line_2”: “Marylebone”,
“city”: “London”,
“postal_code”: “NW1 6XE”
}

A

A

37
Q

How to install mongoose in node.js?

A

npm install mongoose

38
Q

What is the –save option for npm install?

A

When we do “npm install”, then it install the modules. If we need to update the version of module in package.json, then we have to do it manually. BUT when we do “npm install –save”, then it install the modules and update the package.json automatically.

39
Q

What is the difference between package.json and package-lock.json in a Node project?

A

package.json is a versioning file used to install multiple packages in your project. package.json file contains metadata about the project and also the functional dependencies that is required by the application. package.lock.json is created for locking the dependency with the installed version. Without package.lock.json, there might be some differences in installed versions in different environments.

40
Q

What is the difference between dependencies and devDependencies in package.json?

A

Dependencies are modules your project depends on, devDependencies are modules you use to develop your project.
Examples of dependencies are request, through2 and concat-stream. Examples of devDependencies are grunt, mocha, eslint, tape, and browserify.

41
Q

What is likely causing the following error?

npm ERR! Windows_NT 6.3.9600
npm ERR! argv “C:\Program Files (x86)\nodejs\\node.exe” “C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js” “start”
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! path C:\vueproject\package.json
npm ERR! code ENOENT
npm ERR! errno -4058

npm ERR! enoent ENOENT, open ‘C:\vueproject\package.json’
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR! C:\vueproject\npm-debug.log

A

missing package.json

42
Q

Fill in the blanks (comments)

//????????
var mongoose = require(‘mongoose’);

//????????
mongoose.connect(‘mongodb://localhost:27017/mongodb’);

//???????
var userSchema = mongoose.Schema({
name: String, //??????????
username: { type: String, required: true, unique: true }, //????????
password: { type: String, required: true },
admin: Boolean,
location: String,
created_at: Date //???????
});

//???????
var User = mongoose.model(‘User’, userSchema);

//??????
var userDetails = new User({ name: ‘Test user’,username:’testuser’,password:’test12@’,location:’mohali’ });
userDetails.save(function (err) {if (err) console.log (‘Error on save!’)});
console.log(userDetails);

A

//include the js library
var mongoose = require(‘mongoose’);

//establish database connection
mongoose.connect(‘mongodb://localhost:27017/mongodb’);

//Create schema
var userSchema = mongoose.Schema({
name: String, //datatype is string
username: { type: String, required: true, unique: true }, //type is string and its required field and its unique
password: { type: String, required: true },
admin: Boolean,
location: String,
created_at: Date //datatype of date
});

//create User Object
var User = mongoose.model(‘User’, userSchema);

//Save User details in database
var userDetails = new User({ name: ‘Test user’,username:’testuser’,password:’test12@’,location:’mohali’ });
userDetails.save(function (err) {if (err) console.log (‘Error on save!’)});
console.log(userDetails);

43
Q

What is asynchronous programming?

A

Asynchronous programming uses an event loop to run the program. When a task needs to be performed, it’s started, and the code keeps running without waiting for the result. Once the result is ready, an event is triggered, and the program continues executing the code from the event handler. This allows a single thread to handle multiple tasks at once.

44
Q

What’s the output?async function getData() {
return await Promise.resolve(‘I made it!’);
}

const data = getData();
console.log(data);

A: “I made it!”
B: Promise {<resolved>: "I made it!"}
C: Promise {<pending>}
D: undefined`</pending></resolved>

A

An async function always returns a promise. The await still has to wait for the promise to resolve: a pending promise gets returned when we call getData() in order to set data equal to it. If we wanted to get access to the resolved value “I made it”, we could have used the .then() method on data: data.then(res ⇒ console.log(res))` This would’ve logged “I made it!””. The correct answer is C.

45
Q

Pros and cons of promise / why use promise?

A

Advantages: promise can solve callback hell, which greatly enhances the readability and maintainability of nested functions,
Disadvantages: unable to cancel promise, errors need to be captured by callback function; If the callback function is not set, the error thrown by promise will not be reflected to the outside; When it is in the pending state, it is impossible to know which stage it has reached, whether it has just started or is about to complete

46
Q

What is Callback Hell?

A

The asynchronous function requires callbacks as a return parameter. When multiple asynchronous functions are chained together then callback hell situation comes up.

47
Q

What are the major features of VueJS?

A

Virtual DOM: It uses virtual DOM similar to other existing frameworks such as ReactJS, Ember etc. Virtual DOM is a light-weight in-memory tree representation of the original HTML DOM and updated without affecting the original DOM.
Components: Used to create reusable custom elements in VueJS applications.
Templates: VueJS provides HTML based templates that bind the DOM with the Vue instance data
Routing: Navigation between pages is achieved through vue-router
Light weight: VueJS is light weight library compared to other frameworks.

48
Q

What are the lifecycle methods of VueJS?

A

Lifecycle hooks are a window into how the library you’re using works behind-the-scenes. By using these hooks, you will know when your component is created, added to the DOM, updated, or destroyed.

49
Q

Describe the following VUEJS Basic App folder structure

A

1 - App.vue This is typically the root of your application defined in Vue Component file format. It’s usually something that defines the template for your page.
2 - main.js This is usually the JavaScript file that will initialize this root component into a element on your page. It is also responsible for setting up plugins and 3rd party components you may want to use in your app.
3 - router folder may contain the index.js file which contains all the router configurations.
4 - views folder contains components that are related to different views
5 - contains all other components (*.vue files)
6 - the assets folder contains images, css etc. that are used by components

50
Q

What are directives in Vue.js?

A

Directives are instruction for VueJS to do things in a certain way. Essentially, a directive is some special token in the markup that tells the library to do something to a DOM element

51
Q

What are the conditional directives?

A

VueJS provides set of directives to show or hide elements based on conditions. The available directives are: v-if, v-else, v-else-if and v-show

v-if: The v-if directive adds or removes DOM elements based on the given expression. For example, the below button will not show if isLoggedIn is set to false.
<button>Logout</button>
You can also control multiple elements with a single v-if statement by wrapping all the elements in a <template> element with the condition. For example, you can have both label and button together conditionally applied,</template>

<template>
<label> Logout </button>
<button> Logout </button>
</template>
v-else: This directive is used to display content only when the expression adjacent v-if resolves to false. This is similar to else block in any programming language to display alternative content and it is preceded by v-if or v-else-if block. You don’t need to pass any value to this. For example, v-else is used to display LogIn button if isLoggedIn is set to false(not logged in).
<button> Logout </button>
<button> Log In </button>
v-else-if: This directive is used when we need more than two options to be checked. For example, we want to display some text instead of LogIn button when ifLoginDisabled property is set to true. This can be achieved through v-else statement.
<button> Logout </button>
<label> User login disabled </label>
<button> Log In </button>
v-show: This directive is similar to v-if but it renders all elements to the DOM and then uses the CSS display property to show/hide elements. This directive is recommended if the elements are switched on and off frequently.
<span>Welcome user,{{user.name}}</span>Question.
</label></template>

52
Q

What is the purpose of v-for directive?

A

The built-in v-for directive allows us to loop through items in an array or object. You can iterate on each element in the array or object.

53
Q

VUEJS: Name differences between the VUESJ Options and Composition API.

A

The Options API is easier for beginners and aligns with a class-based way of thinking. It centers around component instances and is better for smaller projects.

The Composition API is more organized and preferred for larger and advanced Vue.js applications. It allows for cleaner and easier-to-manage code. It centers around declaring reactive state variables directly in a function scope and composing state from multiple functions to handle complexity. It doesn’t require a large single exportable object like the Options API.

54
Q

What is the vue instance?

A

Every Vue application works by creating a new Vue instance with the Vue function. Generally the variable vm (short for ViewModel) is used to refer Vue instance. You can create vue instance as below,

var vm = new Vue({
// options
})

55
Q

Explain the differences between one-way data flow and two-way data binding?

A

In one-way data flow the view (UI) part of application does not updates automatically when data Model is change we need to write some custom code to make it updated every time a data model is changed. In Vue js v-bind is used for one-way data flow or binding.
In two-way data binding the view (UI) part of application automatically updates when data Model is changed. In Vue.js v-model directive is used for two way data binding.

56
Q

How to make a component in VUEJS?

A

Components in Vue JS are a single, independent unit of an interface. They have their own state, markup, and style.
A Vue component can be defined in four ways.
The first is new Vue({ /*options / }).
The second is Vue.component(‘component-name’, { /
options */ }).
The third way is by using the local components.
The fourth is in the .vue files or Single File Components.
The first two ways are the standard ways to use Vue when building an application that is not a SPA (Single Page Application). The Single File Components are used in the Single Page Application.

57
Q

VUEJS: What is an SFC?

A

Single File Component, the template (UI-part), styling and properties (data and functionality) are in one file.

58
Q

VUEJS: Give an example each for when you would use methods versus computed props in VUJS. Use the examples to explain the difference.

A

Methods are used to react to events which happen in the DOM and they accept arguments. For example some output needs to be shown when a user presses a button
Computed properties are cached, that’s mean that the function will run only once until the values don’t change again and they don’t take arguments. They are often used to do calculation and at the end to return a value. Or they can be used to setup something at the beginning that will be used many times but doesn’t update.

59
Q

How to call a rest API from VUE JS?

A

We can use various HTTP libraries to call REST Api’s from Vue JS. One of the popular libraries is Axios. It simple to use and lightweight. To include it in your project, execute the following command.
npm install axios –save
Implementing GET method using Axios in Vue JS
axios({ method: “GET”, “URL”: “https://httpbin.org/ip” }).then(result => {
this.ip = result.data.origin;
}, error => {
console.error(error);
});
We can send an HTTP request using Axios with a promise. If the request is successful, we’ll get the result.

60
Q

Frontend development: What is the Bootstrap toolkit used for?

A

Collection of templates and functions for user interface and user interactions.

61
Q

What is OWASP?

A

OWASP stands for Open Web Application Security Project. It is an organization which supports secure software development.

62
Q

Name 3 out of the List Top 10 OWASP Vulnerabilities

A

Injection, XSS(Cross Site Scripting), and CSRF(Cross Site Request Forgery).

63
Q

Mention what happens when an application takes user inserted data and sends it to a web browser without proper validation and escaping?

A

Cross site scripting happens when an application takes user inserted data and sends it to a web browser without proper validation and escaping.

64
Q

What is Cross-site scripting?

A

For example, cross-site scripting or XSS is a client-side code injection problem. An attacker getting a victim’s browser to run script content like JavaScript within their browser.

65
Q

What are the Common defenses against XSS?

A

Input Validation and Output Validation with putting concentration on upcoming things.

66
Q

What is cross-site request forgery?

A

A hacker gets a victim’s browser to make requests, with login credentials included without their knowledge. An example for this is an association of IMG tag points to a URL with an action.

67
Q

How to defend against CSRF?

A

To protect against CSRF attacks, you need to ensure that GET requests are side-effect free and that non-GET requests can only come from your client-side code.

One way to protect against CSRF attacks is to only use GET requests for view or read-only actions, which limits the number of vulnerable requests.

However, even if you restrict edit actions to non-GET requests, POST requests can still be sent from other domains. To ensure that you only handle valid HTTP requests, you need to include a unique token with each HTTP response, and verify that token when it’s passed back in subsequent requests. This is called an anti-forgery token.