0% found this document useful (0 votes)
2K views

Web Interview Question

The document contains questions about JavaScript concepts like data types, operators, DOM manipulation, and more. It discusses how to refer to the main window from a popup, the difference between GET and POST methods, and how to detect the operating system and embed JavaScript in a web page.

Uploaded by

Kishore Babu
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views

Web Interview Question

The document contains questions about JavaScript concepts like data types, operators, DOM manipulation, and more. It discusses how to refer to the main window from a popup, the difference between GET and POST methods, and how to detect the operating system and embed JavaScript in a web page.

Uploaded by

Kishore Babu
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

1. What is the difference between undefined value and null value?

2. Are HTML tags case sensitive?


3. What do you understand about? CSS and How many kind of CSS we use?
4. In a pop-up browser window, how do you refer to the main browser window that opened it? 
5. Methods GET and POST in HTML forms - what's the difference?
6. What is === operator ? 
7. How to change style on an element? 
8. How to convert numbers to strings using JavaScript? 
What is decodeURI(), encodeURI() in JavaScript?
9. What are the various datatypes in javascript?
10. How to get CheckBox status whether it is checked or not?
11. What does the "Access is Denied" IE error mean?
12. How to embed JavaScript in a web page?
13. How to Accessing Elements using JavaScript?
14. How to disable right click option?
15. What does “1″+2+4 evaluate to? What about 5 + 4 + “3″?

. What is the difference between undefined value and null value?

undefined means a variable has been declared but has not yet been assigned a value. On the other
hand, null is an assignment value. It can be assigned to a variable as a representation of no value.
Also, undefined and null are two distinct types: undefined is a type itself (undefined) while null is an
object.
Unassigned variables are initialized by JavaScript with a default value of undefined. JavaScript never sets
a value to

null. That must be done programmatically


2. Are HTML tags case sensitive?
Ans No nothing like this HTML tags are not case sensitive. You can use any case as your wish.
3.? What do you understand about? CSS and How many kind of CSS we use?
Ans.? Full form of CSS is? Cascading?Style?Sheets. If you are a designer (HTML/CSS Developer) than you
must have good command on CSS.
You can say CSS i just like as blood in human body. CSS define?how to display?HTML elements
 
There are three types of CSS we can use….
 
(a) Inline style sheet —: We use inside the HTML element
(b) Internal style sheet – : We use inside the HTML page using <style></style> tag
(c) External style sheet : – Separate file or external file

In a pop-up browser window, how do you refer to the main browser window that opened it? 
Use window.opener to refer to the main window from pop-ups.

Methods GET and POST in HTML forms - what's the difference?


GET: Parameters are passed in the querystring. Maximum amount of data that can be sent via the GET
method is limited to about 2kb.
POST: Parameters are passed in the request body. There is no limit to the amount of data that can be
transferred using POST. However, there are limits on the maximum amount of data that can be
transferred in one name/value pair

What is === operator ? 


==== is strict equality operator ,it returns true only when the two operands are having the same value
without any type conversion.

How to change style on an element? 


Between CSS and javascript is a weird symmetry. CSS style rules are layed on top of the DOM. The CSS
property names like "font-weight" are transliterated into "myElement.style.fontWeight". The class of an
element can be swapped out. For example: 
document.getElementById("myText").style.color = "green";
document.getElementById("myText").style.fontSize = "20";
-or-
How to convert numbers to strings using JavaScript? 
You can prepend the number with an empty string 
var mystring = ""+myinteger; 
or 
var mystring = myinteger.toString(); 
You can specify a base for the conversion, 
var myinteger = 14; 
var mystring = myinteger.toString(16);

mystring will be "e"


Javascript string Methods:

 charAt()
 charCodeAt()
 concat()
 fromCharCode()
 indexOf()
 lastIndexOf()
 match()
 replace()
 search()
 slice()
 split()
 substr()
 substring()
 toLowerCase()
 toUpperCase()
 valueOf()

What is decodeURI(), encodeURI() in JavaScript?

To send the characters that can not be specified in a URL should be converted into their
equivalent hex encoding. To perform this task the methods encodeURI() and decodeURI() are
used.
5. What are the various datatypes in javascript?
Number
String
Boolean
Function
Object
Null\
Undefined
32. How to get CheckBox status whether it is checked or not?

alert(document.getElementById('checkbox1').checked);
15. What does "1"+2+4 evaluate to?

Since 1 is a string, everything is a string, so the result is 124.

16. How about 2+5+"8"?

Since 2 and 5 are integers, this is number arithmetic, since 8 is a string, it’s concatenation, so 78 is the
result.
JavaScript
1. In a pop-up browser window, how do you refer to the main browser window that opened it?
Use window.opener to refer to the main window from pop-ups.

2. Methods GET and POST in HTML forms - what's the difference?


GET: Parameters are passed in the query string. Maximum amount of data that can be sent via
the GET method is limited to about 2kb.
POST: Parameters are passed in the request body. There is no limit to the amount of data that
can be transferred using POST. However, there are limits on the maximum amount of data that
can be transferred in one name/value pair.
3. What does the "Access is Denied" IE error mean?
The "Access Denied" error in any browser is due to the following reason.
A JavaScript in one window or frame is tries to access another window or frame whose
document's domain is different from the document containing the script.
4. Are Java and JavaScript the Same?
No.java and JavaScript are two different languages.
Java is a powerful object - oriented programming language like C++,C whereas JavaScript is a
client-side scripting language with some limitations.
5. How to embed JavaScript in a web page?
JavaScript code can be embedded in a web page between <script
language="JavaScript"></script> tags.
6. What Boolean operators does JavaScript support?
&&, || and !.
7. How do you submit a form using JavaScript?
document.formname.submit (); (action attribute to the form should be mentioned).
8. How to read and write a file using JavaScript?
To read and write files from JavaScript, we will use an ActiveX Object from the
Scripting.FileSystemObject library, which knows how to handle files. The second parameter of
the OpenTextFile function represents what we want the object to do with the file (read = 1,
write = 2, append = 8).

And here are the scripts:


a. Reading from file
function ReadFromFile(sText){
var fso = new ActiveXObject(“Scripting.FileSystemObject”);
var s = fso.OpenTextFile(“C:\\example.txt”, 1, true);
row = s.ReadLine(); //also we can use s.ReadAll() to read all the lines;
alert(row);
s.Close();
}

b. Writing to file
function WriteToFile(sText){
var fso = new ActiveXObject(“Scripting.FileSystemObject”);
var s = fso.OpenTextFile(“C:\\example.txt”, 8, true); //if we use 2 instead of 8, the file will be
overwritten;
s.WriteLine(“new line added”);
s.Close();
}
Though, to make this scripts work in Internet Explorer, you must go to Tools/Internet
Options/Security, add your page to Trusted sites, then go to Custom level… and look for
Initialize and script ActiveX controls not marked as safe for scripting. Enable it and
restart the Internet Explorer.
9. How to detect the operating system on the client machine?
In order to detect the operating system on the client machine, the navigator.appVersion
string (property) should be used.
10. How do you convert numbers between different bases in JavaScript?
Use the parseInt() function, that takes a string as the firstparameter, and the base as a second
parameter. So to converthexadecimal 3F to decimal, use parseInt (“3F”, 16);
11. What are JavaScript types?
“Types” in programming languages refer to the type of value a language recognizes.
Javascript recognizes 5 types:
Number (1, 2, 3, 59.45 etc.)
Boolean (true,false)
Strings(“Hello”)
null (no value)
undefined (type of value is not defined)
12. Where are cookies actually stored on the hard disk?
The storage of cookies on the hard disk depends on OS and the browser. The Netscape navigator
on Windows, the file cookies.txt contains all the cookies. The path is :
c:\Program Files\Netscape\Users\username\cookies.txt
The Internet Explorer stores the cookies on a file by name [email protected] is
c:\Windows\Cookies\[email protected]
13. How to Accessing Elements using JavaScript?
Following are some of the functions with which the elements can be retrieved:
getElementById()
getElementsByName()
getElementsByTagName()
14. How to set the cursor to wait in JavaScript?
The cursor can set to wait in JavaScript by using the property ‘cursor’ property. The following
example illustrates the usage.
window.document.body.style.cursor = "wait"; // sets the cursor shape to hour-glass.
15. What is decodeURI(), encodeURI() in JavaScript?
To send the characters that cannot be specified in a URL should be converted into their
equivalent hex-encoding. To perform this task the methods encodeURI() and decodeURI() are
used.
For example, the following code snippet performs the encoding of URL:
<script type="text/javascript">
var uri = http://www.mysite.com?city=Banglore; // original URI
var ncodeuri=encodeURI(uri);
document.write("<br />ncodeuri”);
var dcodeuri = decodeURI(ncodeuri);
document.write(“<br>/>dcodeuri”);
</script>
16. Write javascript to open child window and then close parent window
if (!window.opener){
var newwin=window.open(window.location, name,
"fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,loc
ation=no,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top);
window.opener=""
window.close();
}
17. How to disable right click option?
To disable right click set this in body tag body oncontextmenu="return false;"
<body oncontextmenu="return false;">
</body>
18. How to detect the visitor browser and browser version?
<html>
<script type="text/javascript">
var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version)
document.write("Browser name: "+ browser)
document.write("<br />");
document.write("Browser version: "+ version);
</script>
</html>
19. What is a Cookie?
A cookie is a variable that is stored by a browser on the user's computer. Each time the same
computer requests a page with a browser, it will send the cookie too. With JavaScript, you can
both create and retrieve cookie values.
20. What is the difference between == and === ?
The == checks for value equality, but === checks for both type and value.
21. What does “1″+2+4 evaluate to? What about 5 + 4 + “3″?
Since 1 is a string, everything is a string, so the result is 124. In the second case, its 93.
22. What is the difference between undefined value and null value?
undefined means a variable has been declared but has not yet been assigned a value. On the
other hand, null is an assignment value. It can be assigned to a variable as a representation of no
value.
Also, undefined and null are two distinct types: undefined is a type itself (undefined) while null
is an object.
Unassigned variables are initialized by JavaScript with a default value of undefined. JavaScript
never sets a value to null. That must be done programmatically.

23. How do you change the style/class on any element?


document.getElementById(“myText”).style.fontSize = “20″;
-or-
document.getElementById(“myText”).className = “anyclass”;

CSS
24. Explain the difference between visibility:hidden; and display:none; ?
Visibility:Hidden; - It is not visible but takes up it's original space.
Display:None; - It is hidden and takes up absolutely no space as if it was never there.
25. Name three ways to define a color in html?
a) Hex
b) RGB
c) Name (ie red)
.colorMe {
color:red;
color:#ff0000;
color:rgb(0,0,255);
}
25. What are pseudo-classes?
Pseudo-classes are fictional element types that do not exist in HTML. In CSS1 there is only one
element type which can be classed this way, namely the A element (anchor). By creating three
fictional types of the A element individual style can be attached to each class. These three
fictional element types are: A as unvisited link, A as active link and A as visited link. Pseudo-
classes are created by a colon followed by pseudo-class’s name. They can also be combined with
normal classes,
e.g.:
A:link {background: black; color: white}
A:active {background: black; color: red}
A:visited {background: transparent; color: black}
26. What is selector?
CSS selector is equivalent of HTML element(s). It is a string identifying to which element(s) the
corresponding declaration(s) will apply and as such the link between the HTML document and
the style sheet.
For example in P {text-indent: 10pt} the selector is P and is called type selector as it matches all
instances of this element type in the document.
in P, UL {text-indent: 10pt} the selector is P and UL (see grouping); in .class {text-indent: 10pt}
the selector is .class (see class selector).
27. What is ‘important’ declaration?
Important declaration is a declaration with increased weight. Declaration with increased weight
will override declarations with normal weight. If both reader’s and author’s style sheet contain
statements with important declarations the author’s declaration will override the reader’s.
BODY {background: white ! important; color: black}
In the example above the background property has increased weight while the color property
has normal.
28. Are Style Sheets case sensitive?
No. Style sheets are case insensitive. Whatever is case insensitive in HTML is also case
insensitive in CSS. However, parts that are not under control of CSS like font family names and
URLs can be case sensitive – IMAGE.gif and image.gif is not the same file.
29. Can I include comments in my Style Sheet?
Yes. Comments can be written anywhere where whitespace is allowed and are treated as white
space themselves. Anything written between /* and */ is treated as a comment (white space).
NOTE: Comments cannot be nested.
30. What is the difference between ID and CLASS?
ID identifies and sets style to one and only one occurrence of an element while class can be
attached to any number of elements. By singling out one occurrence of an element the unique
value can be declared to say element.
CSS:
#eva1 {background: red; color: white}
.eva2 {background: red; color: white}
31. Which characters can CSS-names contain?
The CSS-names; names of selectors, classes and IDs can contain characters a-z, A-Z, digits 0-9,
period, hyphen, escaped characters, Unicode characters 161-255, as well as any Unicode
character as a numeric code. The names cannot start with a dash or a digit. (Note: in HTML the
value of the CLASS attribute can contain more characters).
32. What is shorthand property?
Shorthand property is a property made up of individual properties that have a common
“addressee”. For example properties: font-weight, font-style, font-variant, font-size, font-family,
refer to the font. To reduce the size of style sheets and also save some keystrokes as well as
bandwidth they can all be specified as one shorthand property font, e.g.:

H1 {font-weight: bold;
font-style: italic;
font-variant: small-caps;
font-size: 160%;
font-family: serif}
can be all shorthanded to a space separated list:

H1 {font: bold italic small-caps 160% serif}

You might also like