1. What is JavaScript?
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. JavaScript is also an Object based Programming language.
2. What are JavaScript Data Types?
Following are the JavaScript Data types:
- Number
- String
- Boolean
- Object
- Undefined
3. What is the use of isNaN function?
isNan function returns true if the argument is not a number otherwise it is false.
4. What is negative infinity?
Negative Infinity is a number in JavaScript which can be derived by dividing negative number by zero.
5. What is a prompt box?
A prompt box is a box that allows the user to enter input by providing a text box. Label and box will be provided to enter the text or number.
6. What is ‘this’ keyword in JavaScript?
‘This’ keyword refers to the object from where it was called.
7. What is === operator?
=== is called a strict equality operator which returns true when the two operands are having the same value without any type conversion
8. Explain how can you submit a form using JavaScript?
To submit a form using JavaScript use document.form[0].submit();
document.form[0].submit();
9. What are all the looping structures in JavaScript?
Following are looping structures in Javascript:
- For
- While
- do-while loops
10. Explain the difference between “==” and “===”?
“==” checks only for equality in value whereas “===” is a stricter equality test and returns false if either the value or the type of the two variables are different.
11. What are all the types of Pop up boxes available in JavaScript?
- Alert
- Confirm
- Prompt
12. What are the features of JavaScript?
- JavaScript is a lightweight, interpreted programming language.
- JavaScript is designed for creating network-centric applications.
- JavaScript is complementary to and integrated with Java.
- JavaScript is complementary to and integrated with HTML.
- JavaScript is open and cross-platform.
13. How can we create an object in JS?
var object =
{
name: "obj",
age: 10
};
14. How to create an array in js and how to read array elements?
Can you define arrays using the array literal as follows?
- var x = [];
- var y = [1, 2, 3, 4, 5];
An array has a length property that is useful for iteration. Can we read elements of an array as follows?
for (var i = 0; i < x.length; i++)
15. Difference between “var” and “let” Keywords?
- Var was there from the beginning but the let was introduced in ES2015/ES6.
- Let has block scope and “Var” has function scope
16. Why is javascript called Richer Interface?
You can use JavaScript to include such items as drag-and-drop components and sliders to give a Rich Interface to your site visitors.
17. Is javascript case-sensitive?
Yes, JavaScript is a case-sensitive language. This means that language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters.
19. How can we create an object in JS?
var object =
{
name: "obj",
age: 10
};
20. How to create an array in js and how to read array elements?
Can you define arrays using the array literal as follows?
- var x = [];
- var y = [1, 2, 3, 4, 5];
An array has a length property that is useful for iteration. Can we read elements of an array as follows?
for (var i = 0; i < x.length; i++)
21. How can you move the element in lowercase to uppercase from an array?
toUpperCase method returns the calling string value converted to upper case.
22. Explain Closures in JavaScript?
Closures are the combination of lexical environment and function within which the function was declared. This allows JavaScript programmers to write better, more creative, concise and expressive codes. The closure will consist of all the local variables that were in-scope when the closure was created.
23. What is the use of let & const in JavaScript?
In modern javascript let & const are different ways of creating variables. Earlier in javascript, we use the var keyword for creating variables. let & const keyword is introduced in version ES6 with the vision of creating two different types of variables in javascript one is immutable and the other is mutable.
const: It is used to create an immutable variable. Immutable variables are variables whose value is never changed in the complete life cycle of the program.
let: let is used to create a mutable variable. Mutable variables are normal variables like var that can be changed any number of times.
24. List HTML DOM mouse events?
HTML DOM mouse events
- onclick
- ondblclick
- mousemove
- mousedown
- mouseover
- mouseout
- mouseup
25. Difference between const, let and var.
This is an advanced feature from ES6. const, let and var are used for declaring a variable only but they three have different scope.
const : When the value declared in const, the value never changed/modified.
const a = 10;a = 15; // throw error. |
let : When the value declared in let, It will have block scope. Once a variable initialized with let, if we initialized with any type like let, var and const it will throw the error.
for(let i=0;i<3;i++){setTimeout(function(){console.log("i value is " + i);},100);} |
Output is :
i value is 0
i value is 1
i value is 2
var : When the value declared in var, It will have a functional scope.
for(var i=0;i<3;i++){setTimeout(function(){console.log("i value is " + i);},100);} |
Output is :
i value is 3
i value is 3
i value is 3
26. What are Promises used for?
Promises are used for asynchronous programming. They allow Javascript programs to be written in a non-blocking fashion just as using normal callbacks do, but without the mental overhead of that technique. People often refer to the callback hell that often occurs when using callbacks to achieve asynchrony. Promises were created to alleviate this problem.
27) How many types of functions in javascript?
There are 3 types of functions in JavaScript:
- Named function
- Anonymous function
- Immediately invoked function expression. It runs as soon as the browser finds it.
28) What is closure in javascript
JavaScript variables can belong to the local or global scope.
Global variables can be made local (private) with closures.
29) What is a constructor in JavaScript?
A constructor is a function in JavaScript. Its not the function declaration what separates a function from constructor but the function invocation.
A constructor is called with new keyword.
A constructor names must start with a capital letter. Its a convention that should be followed.
function Foo() {};
var f = new Foo();
When a constructor is invoked, the following special actions take place:
- A new empty object is created.
- This object is passed to the constructor as the parameter, and thus becomes the constructor’s function context.
- In the absence of any explicit return value, the new object is returned as the constructor’s value.
The purpose of a constructor is to cause a new object to be created, to set it up, and to return it as the constructor value.
Anything that interferes with that intent isn’t appropriate for functions intended for use as constructors.
Constructors are named as a noun that describes the object that’s being constructed.




tҺe website іѕ really good, I like your website!
If some one wishes expert view concerning running a blog after that i recommend
him/her to go to see this weblog, Keep up the good job.
Amazing! This blog looks exactly like my old one! It’s on a entirely different subject but it has pretty much the same page layout and design. Excellent choice of colors!
I think the admin of this site is really working hard for
his website, for the reason that here every information is quality based data.
Wow, superb blog layout! How long have you been blogging for?
you made blogging look easy. The overall look of your website is great, as well
as the content!