Javascript Interview Questions
Javascript Interview Questions
What is JavaScript?
Ans:JavaScript is a scripting language most often used for client-side web development.
2) What is the difference between JavaScript and Jscript?
Ans:Both JavaScript and Jscript are almost similar. JavaScript was developed by Netscape. Microsoft reverse
engineered Javascript and called it JScript.
3) How do we add JavaScript onto a web page?
Ans:There are several way for adding JavaScript on a web page, but there are two ways which are commonly used
by developers
If your script code is very short and only for single page, then following ways are the best:
a) You can place <script type="text/javascript"> tag inside the <head> element.
Is JavaScript case sensitive?
Ans:Yes!
A function getElementById is not the same as getElementbyID.
5) What are the types used in JavaScript?
Ans:String, Number, Boolean, Function, Object, Null, Undefined.
6) What are the boolean operators supported by JavaScript? And Operator: &&
Or Operator: ||
Not Operator: !
7) What is the difference between “==” and “===”?
Ans:
“==” checks equality only,
“===” checks for equality as well as the type.
8) How to access the value of a textbox using JavaScript?
<input type="text" id="txtFullName"
name="FirstName" value="Vikas Ahlawat">
Collapse | Copy Code
will return true or false.
Consider the following statements and tell what would be the output of the logs statements?
Ans:
console.log(price1 === price2); // Logs true.
console.log(price1 === price3); /* Logs false because price3
contains a complex number object and price 1
is a primitive value. */
What is this?
Name any two JavaScript functions which are used to convert nonnumeric values into numbers?
Number()
parseInt()
parseFloat()
Ans: Yes! Javascript support automatic type conversion. You should take advantage of it, It is most common way of
type conversion used by Javascript developers.
Ex.
var s = '5';
var a = s*1;
var b = +s;
typeof(s); //"string"
typeof(a); //"number"
typeof(b); //"number"
Node.js is a combination of a runtime environment and a library that uses server side Javascript to build web based
applications. Again, the key here is that it is server side Javascript, which means that Javascript is executed by the
server – not the browser. Node.js also happens to use the V8 virtual machine, which is the Javascript virtual
machine that is used in Google’s Chrome web browser.
What is ECMAScript?
ECMAScript is a standard for a scripting language, and the Javascript language is based on the ECMAScript
standard.
JSON
JSON (JavaScript Object Notation) is a standard that is specifically meant for data interchange, and because JSON is
a subset of Javascript, you should be able to use the function above without needing any supporting library files.
The stringify method simply converts the Javascript object into JSON text, which is something that’s very easy to
read and print out to the page.