1) What is JavaScript?
Ans)JavaScript is a lightweight, interpreted programming language with object-oriented capabilities that allows you to build interactivity into otherwise static HTML pages. The general-purpose core of the language has been embedded in Netscape, Internet Explorer, and other web browsers.
2) Name some of the JavaScript features
Ans) Following are the features of JavaScript −
3) What are the advantages of using JavaScript?
Ans)Following are the advantages of using JavaScript −
4)Is JavaScript a case-sensitive language?
Ans) 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.
5)How can you create an Object in JavaScript?
Ans) JavaScript supports Object concept very well. You can create an object using the object literal as follows −
6) How can you read properties of an Object in JavaScript?
7)How can you create an Array in JavaScript?
8) How to read elements of an array in JavaScript?
9)What is a named function in JavaScript? How to define a named function?
10) How many types of functions JavaScript supports?
Ans)A function in JavaScript can be either named or anonymous.
11)How to define a anonymous function?
Ans) An anonymous function can be defined in similar way as a normal function but it would not have any name.
12)Can you assign a anonymous function to a variable?
Ans)Yes! An anonymous function can be assigned to a variable.
13)Can you pass a anonymous function as an argument to another function?
Ans)Yes! An anonymous function can be passed as an argument to another function.
14)What is arguments object in JavaScript?
Ans)JavaScript variable arguments represents the arguments passed to a function.
15) How can you get the type of arguments passed to a function?
16)How can you get the total number of arguments passed to a function?
17) How can you get the reference of a caller function inside a function?
18) What is the purpose of 'this' operator in JavaScript?
Ans) JavaScript famous keyword this always refers to the current context.
19)What are the valid scopes of a variable in JavaScript?
Ans) The scope of a variable is the region of your program in which it is defined. JavaScript variable will have only two scopes.
20) What is the difference between undefined and not defined in JavaScript?
Ans)In JavaScript, if you try to use a variable that doesn't exist and has not been declared, then JavaScript will throw an error var name is not defined and script will stop executing. However, if you use typeof undeclared_variable, then it will return undefined.
21)What is callback?
Ans) A callback is a plain JavaScript function passed to some method as an argument or option. Some callbacks are just events, called to give the user a chance to react when a certain state is triggered.
22)What is closure?
Ans)Closures are created whenever a variable that is defined outside the current scope is accessed from within some inner scope
23)Which built-in method returns the character at the specified index?
Ans)charAt() method returns the character at the specified index.
24)Which built-in method combines the text of two strings and returns a new string?
Ans)concat() method returns the character at the specified index.
25)Which built-in method calls a function for each element in the array?
Ans)forEach() method calls a function for each element in the array.
Ans)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 same as JavaScript, but it is provided by Microsoft.
27)How to use external JavaScript file?
28)How to create function in JavaScript?
29) What is the difference between == and ===?
Ans)The == operator checks equality only whereas === checks equality and data type i.e. value must be of same type.
30) How to write html code dynamically using JavaScript?
31)How to create objects in JavaScript?
32) How to create array in JavaScript?
33)What does the isNaN() function?
Ans) The isNan() function returns true if the variable value is not a number.
34)Difference between Client side JavaScript and Server side JavaScript?
Ans)Difference is:
35)In which location cookies are stored on the hard disk?
Ans) The storage of cookies on the hard disk depends on OS and the browser. The Netscape navigator on Windows uses cookies.txt file that contains all the cookies. The path is : c:\Program Files\Netscape\Users\username\cookies.txt The Internet Explorer stores the cookies on a file username@website.txt. The path is: c:\Windows\Cookies\username@Website.txt.
36)What is the difference between undefined value and null value?
37)How to set the cursor to wait in JavaScript?
38)How to submit a form using JavaScript by clicking a link?
39) How to change the background color of HTML document using JavaScript?
40)How to handle exceptions in JavaScript?
Ans) By the help of try/catch block, we can handle exceptions in JavaScript. JavaScript supports try, catch, finally and throw keywords for exception handling.
41)What is the output of "10"+20+30 in JavaScript?
Ans)102030 because after a string all the + will be treated as string concatenation operator (not binary +).
42)What is the output of 10+20+"30" in JavaScript?
Ans)3030 because 10+20 will be 30. If there is numeric value before and after +, it is treated is binary + (arithmetic operator).
43)Explain how to read and write a file using JavaScript?
Ans) There are two ways to read and write a file using JavaScript
44)How can you convert the string of any base to integer in JavaScript?
45)What do mean by NULL in Javascript?
Ans) 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 array object.
46)What is the use of Void(0)?
Ans)Void(0) is used to prevent the page from refreshing and parameter “zero” is passed while calling.
Void(0) is used to call another method without refreshing the page
47)What is the difference between an alert box and a confirmation box?
Ans) An alert box displays only one button which is the OK button. But a Confirmation box displays two buttons namely OK and cancel.
48)Explain what is pop()method in JavaScript?
49)Whether JavaScript has concept level scope?
Ans)No. JavaScript does not have concept level scope. The variable declared inside the function has scope inside the function.
50)What is break and continue statements?
Ans)Break statement exits from the current loop. Continue statement continues with next statement of the loop.