Simple Javascript Interview Questions

advertisement
Simple Javascript Interview Questions:
1) What is javascript?
Ans. JavaScript is computer programming language which is used to make
interactive web pages and runs on client machine (web browser).
2) What are JavaScript datatypes?
Ans. Number, String, Boolean, Function, Object, Null, Undefined
3) What is ‘this’ keyword in JavaScript?
Ans. 'this' keyword is used to point to the current object in the code.
4) How do we add comments in JavaScript?
Ans. '//'' for Single line comments and /* for MultiLine Comments */
5) How to add external JavaScript file to a HTML page?
Ans. <script type="text/javascript" src="script.js></script>
6) Is JavaScript case sensitive language?
Ans. Yes.
7) What is the difference between == and ===?
Ans. The ==(equality) operator checks equality only whereas ===(strict
equality) operator checks equality as well as data type.
8) How to handle exceptions in a javascript code?
Ans. try{
Code...
}
catch(Exception e){
Code to handle exception
} finally{
Code executes if exception occurs or not
}
9) What is the difference between undefined and null?
Ans. typeof undefined is undefined and typeof null is object.
10)
What are functions in javascript?
Ans. Javascript Function is a block of code which can be executed any
number of time when someone calls it. In Javascript, funtions are first class
objects.
Download