JavaScript, also abbreviated as JS, is a high-level server-side programming language. JavaScript is widely used worldwide to build various web applications.
JavaScript is a scripting or programming language that allows you to implement complex features on web pages — every time a web page does more than just sit there and display static information for you to look at — displaying timely content updates, interactive maps, animated 2D/3D graphics, scrolling video, etc. You can bet that JavaScript is probably involved.
JavaScript can calculate, manipulate and validate data.
Q2. Enumerate the differences between Java and JavaScript?
Java
JavaScript
This is OOP or Object-Oriented programming language.
This is an object-based scripting language.
A stand-alone language.
Not stand-alone.
Strongly typed language is used, and data type of variable is decided before declaring or using it.
Loosely typed, so that the user does not have to worry about the data type before the declaration.
Compiled on the server before it is executed on the client side.
JavaScript is interpreted on the client side.
Slightly more complex.
Easier in comparison.
Large amount of memory is required.
Memory consumption is lesser.
Programs are saved with .java extension.
Programs are saved with JavaScript, .js extension.
Good for the applications which are network-centric
Complementary to Java
Complementary to HTML
Open source
Cross-platform
Q5. Who developed JavaScript, and what was the first name of JavaScript?
JavaScript was developed by Brendan Eich, who was a Netscape programmer.
Brendan Eich developed this new scripting language in just ten days in the year September 1995.
t the time of its launch, JavaScript was initially called Mocha. After that, it was called Live Script and later known as JavaScript.
Q6. What is the use of isNaN function?
isNan function returns true if the argument is not a number, otherwise, it is false.
Q7. Which is faster between JavaScript and an ASP script?
JavaScript is faster. JavaScript is a client-side language, and thus it does not need the assistance of the webserver to execute.
On the other hand, ASP is a server-side language and hence is always slower than JavaScript.
Javascript now is also a server-side language (Nodejs).
Q8. 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.
Q9. Explain Hoisting in javascript?
Hoisting is a default behaviour of javascript where all the variable and function declarations are moved on top.
In JavaScript, a variable can be declared after it has been used.
In other words, a variable can be used before it has been declared.
x = 5; // Assign 5 to x
console.log(x); // Display x in the element
var x; // Declare x
Q10. List some of the advantages of JavaScript?
Server interaction is less
Feedback to the visitors is immediate
Interfaces are richer
Interactivity is high
Q11. List some of the disadvantages of JavaScript?
No support for multithreading
Reading and writing of files is not allowed
No support for networking applications.
No support for multiprocessing
Q12. What is negative Infinity?
Negative Infinity is a number in JavaScript which can be derived by dividing negative number by zero.
Q13. Is it possible to break JavaScript Code into several lines?
Breaking within a string statement can be done by using a backslash, ‘\,’ at the end of the first line.
document. Write ("This is \a program,");
Note: And if you change to a new line when not within a string statement, then javaScript ignores the break in the line
Q14. How can you create an object in JavaScript?
You can create an object using the object literal
var emp = {
name: "Sachid",
age: 30
};
Q15. How can you create an Array in JavaScript?
With the help of array literal we can define arrays.
var x = [];
var y = [1, 2, 3, 4, 5];
Q16. What is a name function in JavaScript & how to define it?
A named function declares a name as soon as it is defined. It can be defined using function keyword.
function named(){
// write code here
}
Q17. Difference between == and === operators?
Both are comparison operators. The difference between both the operators is that, == is used to compare values whereas, === is used to compare both value and types.
var x = 2;
var y = "2";
(x == y) // true because value of both x and y is the same
(x === y) // false because x is "number" and y is "string"
Q18. What is the purpose of the array slice method?
The slice() method returns the selected elements in an array as a new array object. It selects the elements starting at the given start argument, and ends at the given optional end argument without including the last element.
let arrayIntegers = [1, 2, 3, 4, 5];
let arrayIntegers1 = arrayIntegers.slice(0,2); // returns [1,2]
let arrayIntegers2 = arrayIntegers.slice(2,3); // returns [3]
Q19. What is the purpose of the array splice method?
The splice() method is used either adds/removes items to/from an array, and then returns the removed item. The first argument specifies the array position for insertion or deletion whereas the optional second argument indicates the number of elements to be deleted.
let arrayIntegersOriginal1 = [1, 2, 3, 4, 5];
let arrayIntegers1 = arrayIntegersOriginal1.splice(0,2); // returns [1, 2];
Q20. 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.
Q21. Define anonymous function?
It is a function that has no name. These functions are declared dynamically at runtime using the function operator instead of the function declaration.
The function operator is more flexible than a function declaration. It can be easily used in the place of an expression.
var display = function()
{
console.log("Anonymous Function is invoked");
}
display();
Q22. Explain Implicit Type Coercion in javascript?
Implicit type coercion in javascript is automatic conversion of value from one data type to another. It takes place when the operands of an expression are of different data types
var x = 24;
var y = "Hello";
x + y // 24Hello
Q23. Can an anonymous function be assigned to a variable?
Yes, you can assign an anonymous function to a variable.
Q24. What are global variables? How are these variable declared?
Global variables are available throughout the length of the code so that it has no scope. The var keyword is used to declare a local variable or object. If the var keyword is omitted, a global variable is declared.
The problems faced by using global variables are the clash of variable names of local and global scope. Also, it is difficult to debug and test the code that relies on global variables.
globalVar = "Test";
Q25. What is a prompt box?
A prompt box is a box that allows the user to enter input by providing a text box. A label and box will be provided to enter the text or number.
Q26. In JavaScript what is an argument object?
The variables of JavaScript represent the arguments that are passed to a function.
Q27. Define closure
In JavaScript, we need closures when a variable which is defined outside the scope in reference is accessed from some inner scope.
JavaScript variables can belong to the local or global scope.
Global variables can be made local (private) with closures.
var num = 10;
function sum()
{
document.writeln(num+num);
}
sum();
Q28. Is javascript a statically typed or a dynamically typed language?
JavaScript is a dynamically typed language.
In a dynamically typed language, the type of a variable is checked during run-tim.
The type of a variable is checked during compile-time in statically typed language..
Since javascript is a loosely(dynamically) typed language, variables in JS are not associated with any type.
A variable can hold the value of any data type.
var x = 15;
var x = "Hello World!";
Q29. What is the difference between JavaScript and JScript?
Netscape provided the JavaScript language.
Microsoft changed the name and called it JScript to avoid the trademark issue.
In other words, you can say JScript is the same as JavaScript, but Microsoft provides it.
Q30. 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.
Q31. What is Callback?
A 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
var talk = function(fx) {
fx();
}
var sayHi = function() {
console.log('Hi');
}
talk(sayHi); //Hi
Q32. Explain passed by value and passed by reference?
The difference between pass-by-reference and pass-by-value is, pass-by-value creates a new space in memory and makes a copy of a value, whereas pass-by-reference does not.
In JavaScript, primitive data types are passed by value and non-primitive data types are passed by reference.
Refrence
ValueValue
Arrays.
Strings.
Objects.
Numbers.
Booleans.
Undefined.
null.
Q33. What is an Immediately Invoked Function in JavaScript?
An Immediately Invoked Function ( known as IIFE and pronounced as IIFY) is a function that runs as soon as it is defined.
Immediately Invoked Function Expression (IIFE) is one of the most popular design patterns in JavaScript.
It pronounces like iify. IIFE has been used since long by JavaScript community but it had misleading term "self-executing anonymous function".
Now JavaScript provides a variety of methods to define and execute Functions, there are named functions, anonymous functions and then there are Functions that are executed as soon as they are mounted, these functions are known as Immediately Invoked Function Expressions or IIFEs.
(function (){
// Function Logic Here.
})();
Note: It is also used for secure your data to access outside the function.
Q34. What is the purpose of the let keyword?
The let statement declares a block scope local variable. Hence the variables defined with let keyword are limited in scope to the block, statement, or expression on which it is used.
Whereas variables declared with the var keyword used to define a variable globally, or locally to an entire function regardless of block scope.
let counter = 30;
if (counter === 30) {
let counter = 31;
console.log(counter); // 31
}
console.log(counter); // 30 (because the variable in if block won't exist here)
Q35. Explain Higher Order Functions in javascript?
Is it possible to use functions as values?
Assign functions themselves to variables, use them as arguments, or even return?
Yes, that's possible!
A higher-order function is a function that accepts functions as parameters and/or returns a function.
Q36. Differences between declaring variables using var, let and const?
keyword
const
let
var
global scope
no
no
yes
function scope
yes
yes
yes
block scope
yes
yes
no
can be redefined
no
yes
yes
can be redeclared
no
no
yes
Q37. What is the Temporal Dead Zone?
The Temporal Dead Zone is a behavior in JavaScript that occurs when declaring a variable with the let and const keywords, but not with var. In ECMAScript 6, accessing a let or const variable before its declaration (within its scope) causes a ReferenceError.
The time spanwhen that happens, between the creation of a variable’s binding and its declaration, is called the temporal dead zone.
function somemethod() {
console.log(counter1); // undefined
console.log(counter2); // ReferenceError
var counter1 = 1;
let counter2 = 2;
}
Q38. What is memoization
Memoization is a programming technique which attempts to increase a function’s performance by caching its previously computed results.
Each time a memoized function is called, its parameters are used to index the cache. If the data is present, then it can be returned, without executing the entire function.
Otherwise the function is executed and then the result is added to the cache.
Q39. How are object properties assigned?
Properties are assigned to objects in the following way –
1. obj["class"] = 12;
2. obj.class = 12;
Q40. What is Lexical Scope?
Lexical scope means that in a nested group of functions, the inner functions have access to the variables and other resources of their parent scope.
This means that the child's functions are lexically bound to the execution context of their parents.
Lexical scope is sometimes also referred to as static scope.
function add() {
let a = 10;
function plus() {
console.log(a);
}
plus();
}
add();
Q41. What is a window.onload and onDocumentReady?
The window.onload function is not run until all the information on the page is loaded.
onDocumentReady loads the code just after the DOM is loaded.
window.onload: A normal JavaScript event.
onDocumentReady : A specific jQuery event when the entire HTML has been loaded.The window.onload function is not run until all the information on the page is loaded.
onDocumentReady loads the code just after the DOM is loaded.
window.onload: A normal JavaScript event.
onDocumentReady : A specific jQuery event when the entire HTML has been loaded.
Q42. What is currying in JavaScript?
Currying is an advanced technique to transform a function of arguments n, to n functions of one or less arguments.
Timers are used to execute a piece of code at a set time or repeat the code in a given interval. This is done by using the functions setTimeout, setInterval, and clearInterval.
The setTimeout(function, delay) function is used to start a timer that calls a particular function after the mentioned delay.
The setInterval(function, delay) function repeatedly executes the given function in the mentioned delay and only halts when canceled.
The clearInterval(id) function instructs the timer to stop.
Q44. What are the variable naming conventions in JavaScript?
You should not use any of the JavaScript reserved keyword as variable name. For example, break or boolean variable names are not valid.
JavaScript variable names should not start with a numeral (0-9). They must begin with a letter or the underscore character. For example, 123name is an invalid variable name but _123name or name123 is a valid one.
JavaScript variable names are case sensitive. For example, Test and test are two different variables.
Q45. How does TypeOf Operator work?
The typeof operator is used to get the data type of its operand. The operand can be either a literal or a data structure such as a variable, a function, or an object.
The NULL value is used to represent no value or no object.
It implies no object or null string, no valid boolean value, no number, and no arrayobject.
Q52. What is an undefined value in JavaScript?
Undefined value means the
1.Variable used in the code doesn’t exist 2.Variable is not assigned to any value 3.Property does not exist.
var myVar;
alert(myVar); // undefined
Q53. What are all the types of Pop-up boxes available in JavaScript?
1. Alert 2. Confirm and 3. Prompt
Q54. What is the difference between an alert box and a confirmation box?
An alert box displays only one button, which is the OK button.
But a Confirmation box displays two buttons, namely OK and cancel.
An alert box is used to inform/alert the user about an event.
A Confirmation Box is used to provide user with a choice about an event.
Alert Box can be called using the function alert(“message”)
Confirmation Box can be called using the function confirm(“message”)
Q55. What are JavaScript Cookies?
Cookies are data, stored in small text files, on your computer.
When a web server has sent a web page to a browser, the connection is shut down, and the server forgets everything about the user.
Cookies were invented to solve the problem "how to remember information about the user":
When a user visits a web page, his/her name can be stored in a cookie.
Next time the user visits the page, the cookie "remembers" his/her name. Cookies are saved in name-value pairs like:
city = New Delhi
Note: None of the examples above will work if your browser has local cookies support turned off.
Q56. What a pop() method in JavaScript is?
The pop() method is similar to the shift() method, but the difference is that the Shift method works at the array’s start. The pop() method takes the last element off of the given array and returns it. The array on which it is called is then altered.
var cloths = ["Shirt", "Pant", "T-shirt"];
cloths.pop(); // Shirt, Pant
Q57. What is break and continue statements?
Break statement exits from the current loop.
Continue statement continues with next statement of the loop.
Q58. Which keywords are used to handle exceptions?
Try… Catch—finally is used to handle exceptions in the JavaScript
Try{
Code
}
Catch(exp){
Code to throw an exception.
}
Finally{
Code runs either it finishes successfully or after catch
}
Q59. What is variable typing?
Variable typing assigns a number to a variable and then assigns a string to the same variable. An example is as follows:
i = 8;
i = "Deepak";
Q60. What are the different types of errors in JavaScript?
There are three types of errors:
1. Load time errors: Errors that come up when loading a web page, like improper syntax errors, are known as Load time errors and generate the errors dynamically.
2. Runtime errors: Errors that come due to misuse of the command inside the HTML language.
3. Logical Errors: These are the errors that occur due to the bad logic performed on a function with a different operation.
Q61. What is the use of the Push method in JavaScript?
The push method is used to add or append one or more elements to an Array end.
Using this method, we can append multiple elements by passing multiple arguments.
The push() method changes the length of the array.
document.write(decodeURI(uri)); // my test.asp?name=ståle&car=saab
Q66. What is ECMASCRIPT?
ECMAScript 2015 was the second major revision to JavaScript.
ECMAScript 2015 is also known as ES6 and ECMAScript 6.
It is the first major update to the language since ES5 which was standardized in 2009. Therefore, ES2015 is often called ES6.
Q67. New Features in ES6?
1. let keyword 2. const keyword 3. Arrow Functions (Fat Arrow) 4. For/of 5. Map Objects 6. Set Objects 7. Classes 8. Promises 9. Function Rest Parameter 10. Array.from()
Q68. What are the important JavaScript Array Methods?
Length –> If you want to know the number of elements in an array, you can use the length.
prototype –> If you want to add new properties and methods, you can use the prototype.
reverse –> You can reverse the order of items in an array using a reverse method.
sort –> You can sort the items in an array using sort method.
pop –> You can remove the last item of an array using a pop method.
shift –> You can remove the first item of an array using shift method.
push –> You can add a value as the last item of the array.
unshift -> You can add a value as the first item of the array.
Q69. What is JavaScript Unit Testing?
JavaScript Unit Testing is a testing method in which JavaScript tests code written for a web page or web application module.
It is combined with HTML as an inline event handler and executed in the browser to test if all functionalities work fine.
Q70. What are the challenges in JavaScript Unit Testing?
1. Many other languages support unit testing in browsers, in the stable as well as in runtime environment, but JavaScript can not.
2. You can understand some system actions with other languages, but this is not the case with JavaScript.
3. Some JavaScript are written for a web application that may have multiple dependencies.
4. JavaScript is good to use in combination with HTML and CSS rather than on the web.
5.Difficulties with page rendering and DOM manipulation.
6. Sometimes you find an error message on your screen regarding ‘Unable to load example.js’ or any other JavaScript error regarding version control. These vulnerabilities come under Unit Testing JavaScript
Q71. Solutions of JavaScript Unit Testing?
1. Do not use global variables. 2. Do not manipulate predefined objects. 3. Design core functionalities based on the library. 4. Try to create small pieces of functionalities with lesser dependencies.
Q72. What are some important JavaScript Unit Testing Frameworks?
Unit.js: It is known as an open-source assertion library running on browser and Node.js.
QUnit: It is used for both client-side and server-side JavaScript Unit Testing. This Free JavaScript testing framework is used for jQuery projects.
Jasmine: Jasmine is the behavior-driven development framework to unit test JavaScript. It is used for testing both synchronous and asynchronous JavaScript codes.
Karma: Karma is an open-source productive testing environment. Easy workflow control running on the command line.
Mocha: Mocha runs on Node.js and in the browser. Mocha performs asynchronous testing more simply.
Jest: Facebook uses jest so far to test all the JavaScript code. It provides the ‘zero-configuration testing experience.
AVA: AVA is a simple JavaScript Unit Testing Framework. Tests are being run in parallel and serially.
Q73. What is DOM in JavaScript?
JavaScript can access all the elements in a web page using the Document Object Model (DOM). The web browser creates a DOM of the webpage when the page is loaded.
1. JavaScript can change all the HTML elements in the page 2. JavaScript can change all the HTML attributes in the page 3. JavaScript can change all the CSS styles in the page 4. JavaScript can remove existing HTML elements and attributes 5. JavaScript can add new HTML elements and attributes 6. JavaScript can create new HTML events in the page
Q74. What is External JavaScript?
You plan to display the current date and time on all your web pages. Suppose you wrote the code and copied it in to all your web pages. But later, you want to change the format in which the date or time is displayed. In this case, you will have to make changes to all the web pages. This will be a very time-consuming and difficult task.
So, save the JavaScript code in a new file with the extension .js. Then, add a line of code in all your web pages to point to your .js file like this:
Q75. When to Use Internal and External JavaScript Code?
If you have only a few lines of code that is specific to a particular webpage. In that case, it is better to keep your JavaScript code internal within your HTML document.
On the other hand, if your JavaScript code is used in many web pages, you should consider keeping your code in a separate file. If you wish to make some changes to your code, you have to change only one file, making code maintenance easy. If your code is too long, it is better to keep it in a separate file. This helps in easy debugging.
Q76. How do you manipulate DOM using a service worker?
Service worker can't access the DOM directly.
But it can communicate with the pages it controls by responding to messages sent via the postMessage interface, and those pages can manipulate the DOM.
Q77. What is the use of a constructor function in JavaScript?
Constructor functions are used to create objects in JavaScript.
When do we use constructor functions?
If we want to create multiple objects having similar properties and methods, constructor functions are used.
function Person(name,age,gender){
this.name = name;
this.gender = gender;
}
var person1 = new Person(“Sacchid", "male");
var person2 = new Person(“Soumya", "female");
Q78. What are arrow functions?
Arrow functions were introduced in the ES6 version of JavaScript.
They provide us with a new and shorter syntax for declaring functions.
Arrow functions can only be used as a function expression.
Arrow functions are declared without the function keyword. If there is only one returning expression, then we don’t need to use the return keyword.
Also, for functions having just one line of code, curly braces { } can be omitted.
var add = function(a,b){
return a + b;
}
var arrowAdd = (a,b) => a + b;
Q79. What is the rest parameter?
It provides an improved way of handling parameters of a function.
Using the rest parameter syntax, we can create functions that can take a variable number of arguments.
Any number of arguments will be converted into an array using the rest parameter.
It also helps in extracting all or some parts of the arguments.
Rest parameter can be used by applying three dots (...) before the parameters.
function extractingArgs(a, ...args){
return args[1];
}
Note: Rest parameter should always be used at the last parameter of a function
Q80. What is spread operator?
Although the syntax of spread operator is the same as the rest parameter, spread operator is used to spread an array, and object literals.
Spread operator (...) allows us to quickly copy all or part of an existing array or object into another array or object.
let obj1 = {name: 'Sahil', age: 25};
let obj2 = {gender: 'Male', address: 'New Delhi’};
let mergedObj = {...obj1, ...obj2};
console.log(mergedObj);
Q81. What is the real name of JavaScript?
The original name was Mocha, a name chosen by Marc Andreessen, founder of Netscape.
In September of 1995, the name was changed to LiveScript.
In December 1995, after receiving a trademark license from Sun, the name JavaScript was adopted.
Q82. What is the difference between undefined value and null value?
Undefined: undefined means a variable has been declared but has not yet been assigned a value.
Ex:
var testVar; // Here, a testVar has an undefined value.
Null: null is an assignment value. It can be assigned to a variable as a representation of no value.
Ex:
var testVar = null; // Here, testVar has a null value.
Q83. How do you access history in JavaScript?
The window.history object contains the browser's history.
You can load previous and next URLs in the history using back() and next() methods.
function goBack() {
window.history.back()
}
function goForward() {
window.history.forward()
}
Q84. What is design pattern in JavaScript?
Design patterns are reusable solutions to commonly occurring problems in software design.
The Singleton Pattern limits the number of instances of a particular object to just one. This single instance is called the singleton
Q86. Different types of storage in browser?
1. Cookies.
2. Local storage.
3. Session storage.
4. IndexedDB.
5. Web SQL.
6. Cache storage.
Q87. What is undefined and not defined?
If the variable name which is being accessed doesn’t exist in memory space then it would be not defined.
Ex:
console.log(a); // ReferenceError: a is not defined
If exists in memory space but hasn’t been assigned any value till now, then it would be undefined.
Ex:
var b;
console.log(b); // undefined
Q88. Different types of selector in JavaScript?
1. Id (getElementById())
2. Class (getElementsByClassName())
3. li, div, h1 (getElementsByTagName())
Q89. What is Throttling?
Throttling is a technique in which, no matter how many times the user fires the event, the attached function will be executed only once in a given time interval.
Ex:
Now, when throttling is applied with 5000 milliseconds (5 sec.) to the function(), no matter how many times the user clicks on the button, it will hit only once in 5000 milliseconds.
Throttling ensures that the function executes at a regular interval.
Q90. What is Debouncing?
In the Debouncing technique, no matter how many times the user fires the event, the attached function will be executed only after the specified time once the user stops firing the event.
Ex:
Suppose a user is clicking a button 5 times in 100 milliseconds. Debouncing will not call that function.
Once the user has stopped clicking, if debouncing time is 100 milliseconds, the function will be executed after 100 milliseconds.
Q91. What is mutable and immutable in JavaScript?
If an item is mutable, modifying the copy also modifies the original.
If it’s immutable, modifying the copy does not affect the original.
/*============== immutable ================ */
var num1 = 42;
// Copy items
var num2 = num1;
// Update the copies
num2 = num2 - 10;
console.log(num1); // Logs 42
var obj = {name: ‘Praveen', email: ‘praveen@gmail.com’};
var objClone1 = {...obj};
var objClone2 = Object.assign({}, obj);
var objClone3 = JSON.parse(JSON.stringify(obj));
Q93. How can we merge more than one array?
There are 3 methods to merge array in JavaScript:
var output1 = [...array1, ...array2]; // using spread operator
var output2 = array1.concat(array2); // using concat
var output3 = array1.push(...array2); // using array push
Q94. Types of data structures in JavaScript?
1. Array 2. Queues 3. Linked List 4. Trees 5. Graphs 6. Hash Tables (Map)
Q95. What is array.prototype in JavaScript?
The JavaScript array prototype constructor is used to allow to add new methods and properties to the Array() object.
If the method is constructed, then it will be available for every array. When constructing a property, All arrays will be given the property, and its value, as default.
function Person(first, last, age, eye) {
this.firstName = first;
this.lastName = last;
this.age = age;
this.eyeColor = eye;
}
const myFather = new Person(“Anamika", “Shri", 25, "blue"); const myMother = new Person(“Vivek", “Yadav", 28, “black");
Person.nationality = 'Indian'; // undefined //It will add Nationality for all constructor but you can not use it, coz it will add as prototype
myFather.nationality = 'Indian'; // It will add Nationality only for Father's constructor not for Mother's
Person.prototype.nationality = "Indian"; // It will add Nationality for all constructor now we can use it, but still it's as prototype
Note: It rejects immediately upon any of the input promises rejecting or non-promises throwing an error and will reject with this first rejection message / error.
Q97. What is recursion in a programming language?
Recursion is a technique to iterate over an operation by having a function call itself repeatedly until it arrives at a result.
function add(number) {
if (number <= 0) {
return 0;
} else {
return number + add(number - 1);
}
}
Q98. What is the difference between ViewState and SessionState?
ViewState is specific to a page in a session.
SessionState is specific to user-specific data that can be accessed across all web application pages.
Q99. What is the difference between Attributes and Property?
Attributes- provide more details on an element like id, type, value etc.
Property- is the value assigned to the property like type=”text”, value=’Name’ etc.
Q100. What is BOM?
BOM stands for Browser Object Model. It provides interaction with the browser.
The default object of a browser is a window. So, you can call all the functions of the window by specifying the window or directly.
The window object provides various properties like document, history, screen, navigator, location, innerHeight, innerWidth
Q101. What is the difference between innerHTML & innerText?
innerHTML – It will process an HTML tag if found in a string
innerText – It will not process an HTML tag if found in a string
Cookie Policy
This website uses cookie or similar technologies, to enhance your browsing experience and provide personalised recommendations. By continuing to use our website, you agree to our Cookie Policy.