Sunday, 21 February 2021

IP UNIT-2 TWO MAKRS WITH ANSWERS

 What is JavaScript?

JavaScript is a lightweightinterpreted programming language with object-oriented capabilities that allows you to build interactivity into otherwise static HTML pages. JavaScript is a client-side as well as server side scripting language that can be inserted into HTML pages and is understood by web browsers.

What are the data types supported by JavaScript?

The data types supported by JavaScript are:

  • Undefined
  • Null
  • Boolean
  • String
  • Symbol
  • Number
  • Object

What are the features of JavaScript?

Following are the features of JavaScript:

  • It is a lightweight, interpreted programming language.
  • It is designed for creating network-centric applications.
  • It is complementary to and integrated with Java.
  • It is an open and cross-platform scripting language.

Is JavaScript a case-sensitive language?

Yes, JavaScript is a case sensitive language.  The language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters.

What are the advantages of JavaScript?

Following are the advantages of using JavaScript −

  • Less server interaction − You can validate user input before sending the page off to the server. This saves server traffic, which means less load on your server.
  • Immediate feedback to the visitors − They don’t have to wait for a page reload to see if they have forgotten to enter something.
  • Increased interactivity − You can create interfaces that react when the user hovers over them with a mouse or activates them via the keyboard.
  • Richer interfaces − You can use JavaScript to include such items as drag-and-drop components and sliders to give a Rich Interface to your site visitors.

How can you create an object in JavaScript?

JavaScript supports Object concept very well. You can create an object using the object literal as follows −

varemp = {
name: "Daniel",
age: 23
};

How can you create an Array in JavaScript?

You can define arrays using the array literal as follows-

var x = [];
var y = [1, 2, 3, 4, 5];

What are the scopes of a variable in JavaScript?

The scope of a variable is the region of your program in which it is defined. JavaScript variable will have only two scopes.

  • Global Variables − A global variable has global scope which means it is visible everywhere in your JavaScript code.
  • Local Variables − A local variable will be visible only within a function where it is defined. Function parameters are always local to that function.

What is the purpose of ‘this’ operator in JavaScript?

The JavaScript this keyword refers to the object it belongs to. This has different values depending on where it is used. In a method, this refers to the owner object and in a function, this refers to the global object.

What is Callback?

callback is a plain JavaScript function passed to some method as an argument or option. It is a function that is to be executed after another function has finished executing, hence the name ‘call back‘. 

How to create a cookie using JavaScript?

The simplest way to create a cookie is to assign a string value to the document. Cookie object, which looks like this-

document.cookie = "key1 = value1; key2 = value2; expires = date";

In how many ways a JavaScript code can be involved in an HTML file?

There are 3 different ways in which a JavaScript code can be involved in an HTML file:

  • Inline
  • Internal
  • External

What are the ways to define a variable in JavaScript?

The three possible ways of defining a variable in JavaScript are:

  • Var – The JavaScript variables statement is used to declare a variable and, optionally, we can initialize the value of that variable. Example: var a =10; Variable declarations are processed before the execution of the code.
  • Const – The idea of const functions is not allow them to modify the object on which they are called. When a function is declared as const, it can be called on any type of object.

Let – It is a signal that the variable may be reassigned, such as a counter in a loop, or a value swap in an algorithm. It also signals that the variable will be used only in the block it’s defined in.

What is a Typed language?

Typed Language is in which the values are associated with values and not with variables. It is of two types:

  • Dynamically: in this, the variable can hold multiple types; like in JS a variable can take number, chars.
  • Statically: in this, the variable can hold only one type, like in Java a variable declared of string can take only set of characters and nothing else.

What is the difference between window & document in JavaScript?

Window

Document

JavaScript window is a global object which holds variables, functions, history, location.

The document also comes under the window and can be considered as the property of the window.


What is NaN in JavaScript?
NaN is a short form of Not a Number. Since NaN always compares unequal to any number, including NaN, it is usually used to indicate an error condition for a function that should return a valid number. When a string or something else is being converted into a number and that cannot be done, then we get to see NaN.

What is the DOM?
The Document Object Model (DOM) is a programming interface for HTML and XML documents. It represents the page so that programs can change the document structure, style, and content. The DOM represents the document as nodes and objects.
API = DOM + JavaScript

List out the various 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.
How exceptions are handled in javascript?
By the help of try/catch block, we can handle exceptions in JavaScript. JavaScript supports try, catch, finally and throw keywords for exception handling.

What are the javascript built-in objects?
JavaScript has several built-in or core language objects. These built-in objects are available regardless of window content and operate independently of whatever page your browser has loaded.

Mention the methods of Date object.
  • Date() - Returns today's date and time
  • getDate() - Returns the day of the month for the specified date
  • getDay() - Returns the day of the week for the specified date
  • getFullYear() - Returns the year of the specified date
  • getHours() - Returns the hour in the specified date according to local time.
  • getMilliseconds() - Returns the milliseconds in the specified date according to local time.
What are regular expressions in javascript?
Regular expressions are patterns used to match character combinations in strings. In JavaScript, regular expressions are also objects. These patterns are used with the exec() and test() methods of RegExp, and with the match()matchAll()replace()search(), and split() methods of String.

How is javascript used for validation?
JavaScript provides a way to validate form's data on the client's computer before sending it to the web server. Form validation generally performs two functions.
  • Basic Validation − First of all, the form must be checked to make sure all the mandatory fields are filled in. It would require just a loop through each field in the form and check for data.
  • Data Format Validation − Secondly, the data that is entered must be checked for correct form and value. Your code must include appropriate logic to test correctness of data.
What is an event?
JavaScript's interaction with HTML is handled through events that occur when the user or the browser manipulates a page. Events are a part of the Document Object Model (DOM) Level 3 and every HTML element contains a set of events which can trigger JavaScript Code.

What is DHTML?
Dynamic HTML, or DHTML, is a collection of technologies used together to create interactive and animated websites by using a combination of a static markup language (such as HTML), a client-side scripting language (such as JavaScript), a presentation definition language (such as CSS), and the Document Object Model (DOM).

What is JSON?
JSON is the abbreviation of JavaScript Object Notation. It is one of the simplest data interchange format. It is also independent of programming language and platform. Its lightweight text-based structure makes it easily readable by a human. It is derived from JavaScript for presenting simple data in the form of key-value pairs.

What is meant by JSON objects?
An object is defined as a set of key-value pairs. A JSON starts with a left brace “{“ and ends with another right brace “}”. Every key is followed by a colon “:” and the key-value pairs are separated from each other by using a comma “,”. So, basically, JSON object is a collection of keys along with their values arranged in a pre-specified JSON format.

What is the extension of the JSON file?
A JSON file has an extension of “.json”. Being in a text-based format, a JSON file can be viewed or edited using any text editor like notepad or notepad++.

What are the advantages and features of JSON?
  • Easy to use and fast nature. JSON syntax offers easy parsing of data and even faster implementation. The light-weight structure of JSON allows it to respond at a much faster rate.
  • Compatible with numerous operating systems and browsers. This allows JSON schema to be attuned to many platforms without requiring any extra effort to make sure its compatibility with another platform.
  • Supports a wide range of data types including integers, double, String, Boolean, etc.
What are the limitations of JSON?
  • As the data gets complex with several nested or hierarchical structures, it becomes complex for human readability.
  • JSON is not suitable for handling very complex large data.
  • JSON doesn’t have support for handling multimedia formats such as rich text or images.
  • It doesn’t support comments.
What are the uses of JSON?
  • JSON is mainly used for data interchange between two systems.
  • JSON is prominently used for transmission of serialized data over a network connection between two systems.
  • APIs and web services use JSON to format and transfer data.
  • JSON can be used in combination with most of the modern programming languages.
  • JSON can be used with JavaScript applications such as browser plugins and websites.
  • JSON can be used to read data from the web server and display data on the web pages.
Explain JSON syntax rules?
There are several rules that describe the structure of the JSON. They are:
  • Data inside a JSON is arranged in Key value pair. The left side represents the key and the data on the right side represents value. Both key and value are separated by a colon “:”.
  • Each set of key-value pair is separated from the other pair by using a comma “,”.
  • Curly braces define the JSON objects. Left curly brace “{“ represents the start of the object and right curly brace “}” represents the end of an object.
  • Arrays are defined inside a JSON object by using square brackets “[ ]”.
What are the advantages of JSON over XML?
  • JSON is lighter and faster than the XML.
  • JSON has object types but XML doesn’t define objects as types. JSON has different object type for a different set of data such as string, integer, Boolean, array, etc. All XML objects are categorized as just one data type, i.e. string.
  • JSON data can be easily accessed as a JSON object using JavaScript. On the other hand, the XML data need to be parsed and allocated to the variables using APIs. Getting value out of a JSON is as easy as reading an object from your JavaScript programming.
Name the browsers that support JSON format?
Support for JSON is included in almost all the new versions of the browsers. Internet Explorer, Chrome, Safari, Mozilla Firefox, etc. all support JSON format.

IP UNIT-1 TWO MARKS WITH ANSWERS

What is internet?
The Internet is a global system of interconnected computer networks that use the standard Internet protocol suite (TCP/IP) to link several billion devices worldwide. It is a network of networks that consists of millions of private, public, academic, business, and government networks of local to global scope, linked by a broad array of electronic, wireless, and optical networking technologies. 

What is Web 2.0?

Web 2.0 is describes a second generation of the World Wide Web that is focused on the ability for people to collaborate and share information online. Web 2.0 basically refers to the transition from static HTML Web pages to a more dynamic Web that is more organized and is based on serving Web applications to users.

What are the features of Web 2.0?

·         Allows users to collectively classify and find information 

·         Dynamic content; responsive to user input

·         Information flows two ways between site owner and site user by means of evaluation, review, and commenting.

·         API to allow automated usage

What's the difference between intranet, extranet and internet?

Intranet is shared content accessed by members within a single organization.

Extranet is shared content accessed by groups through cross-enterprise boundaries.

Internet is global communication accessed through the Web.

Define WWW.

The World Wide Web (www, W3) is an information system of interlinked hypertext documents that are accessed via the Internet and built on top of the Domain Name System.

What is role of HTTP in accessing a web page?

HTTP defines how messages are formatted and transmitted, and what actions Web servers and browsers should take in response to various commands. 

Define URL.

A uniform resource locator (URL) is a reference to a resource that specifies the location of the resource on a computer network and a mechanism for retrieving it. 

What is website?

A website, also written as web site, or simply site, is a set of related web pages typically served from a single web domain. A website is hosted on at least one web server, accessible via a network such as the Internet or a private local area network through an Internet address known as a uniform resource locator (URL).

What is web browser?

A web browser is a software application for retrieving, presenting and traversing information resources on the World Wide Web.

What is web server?

Web servers are computers that deliver (serves up) Web pages. The primary function of a web server is to store, process and deliver web pages to clients. The communication between client and server takes place using the Hypertext Transfer Protocol (HTTP). Pages delivered are most frequently HTML documents, which may include images, style sheets and scripts in addition to text content.

How does DNS help in finding web server?

Every Web server has an IP address and possibly a domain name. These details are kept at DNS system which helps the client to find the web server over the internet.

Define web document or web page.

A document on the World Wide Web, consisting of a hypertext file and any related files for scripts and graphics, and often hyperlinked to other documents on the Web.

What are the types of web documents?

a.     Static webpage

b.    Dynamic webpage

Define HTML.

HTML stands for Hyper Text Markup Language. It is the dominant markup language for creating websites and anything that can be viewed in a web browser.

What is HTML 5.0?

HTML 5 is a new standard for HTML whose main target is to deliver everything without need to any additional plugins like flash, Silverlight etc.

What does DOCTYPE mean?

The term DOCTYPE tells the browser which type of HTML is used on a webpage. In turn, the browsers use DOCTYPE to determine how to render a page.

What are some new HTML5 markup elements?

  • <article>
  • <aside>
  • <bdi>
  • <command>
  • <details>
  • <figure>
  • <figcaption>
  • <summary>
  • <header>
  • <footer>
  • <hgroup>
  • <mark>
  • <meter>
  • <nav>
  • <progress>
  • <ruby>
  • <rt>
  • <section>
  • <time>
  • <wpr>
Define CSS.

Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language like HTML. CSS is designed to enable the separation of presentation and content, including layout, colors, and fonts
Mention various types of CSS.
  1. Internal CSS
  2. External CSS
  3. Embedded CSS

What are external style sheets?
The style sheets which has been stored in separate files and included in an HTML documents through the use of a link element are known as external style sheets.

What are embedded style sheets?
A style sheet that is included in the content of a style element is known as an embedded style sheet.

What are the two methods of implementing style sheets?
The two methods of implementing styles to HTML elements are
  1. Rule Cascading
  2. Inheritance

Give some advantages of using cascading style sheets.
  • Making changes to the layout
  • File Size
  • Search Engines
  • Accessibility
  • Consistency

Mention the need for cascading style sheets.
A CSS (cascading style sheet) file allows you to separate your web sites (X)HTML content from it’s style. As always you use your (X)HTML file to arrange the content, but all of the presentation (fonts, colors, background, borders, text formatting, link effects & so on…) are accomplished within a CSS.