1. Difference between window.onload and onDocumentReady?
The onload event does not fire until every last piece of the page is
loaded, this includes css and images, which means there’s a huge delay
before any code is executed.
That isnt what we want. We just want to wait until the DOM is loaded and is able to be manipulated. onDocumentReady allows the programmer to do that.
That isnt what we want. We just want to wait until the DOM is loaded and is able to be manipulated. onDocumentReady allows the programmer to do that.
2. What is the difference between == and === ?
The == checks for value equality, but === checks for both type and value.
3. 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.
4. 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.
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.
5. How do you change the style/class on any element?
document.getElementById(“myText”).style.fontSize = “20″;
-or-
document.getElementById(“myText”).className = “anyclass”;
-or-
document.getElementById(“myText”).className = “anyclass”;
6. What are Javascript closures?When would you use them?
Two one sentence summaries:
* a closure is the local variables for a function – kept alive after the function has returned, or
* a closure is a stack-frame which is not deallocated when the function returns.
* a closure is a stack-frame which is not deallocated when the function returns.
A closure takes place when a function creates an environment that
binds local variables to it in such a way that they are kept alive after
the function has returned. A closure is a special kind of object that
combines two things: a function, and any local variables that were
in-scope at the time that the closure was created.
The following code returns a reference to a function:
function sayHello2(name) {
var text = ‘Hello ‘ + name; // local variable
var sayAlert = function() { alert(text); }
return sayAlert;
}
var text = ‘Hello ‘ + name; // local variable
var sayAlert = function() { alert(text); }
return sayAlert;
}
Closures reduce the need to pass state around the application. The
inner function has access to the variables in the outer function so
there is no need to store the information somewhere that the inner
function can get it.
This is important when the inner function will be called after the
outer function has exited. The most common example of this is when the
inner function is being used to handle an event. In this case you get no
control over the arguments that are passed to the function so using a
closure to keep track of state can be very convenient.
7. What is unobtrusive javascript? How to add behavior to an element using javascript?
Unobtrusive Javascript refers to the argument that the purpose of
markup is to describe a document’s structure, not its programmatic
behavior and that combining the two negatively impacts a site’s
maintainability. Inline event handlers are harder to use and maintain,
when one needs to set several events on a single element or when one is
using event delegation.
1
| <input type= "text" name= "date" /> |
Say an input field with the name “date” had to be validated at runtime:
1
2
3
4
5
6
| document.getElementsByName( "date" )[0]. addEventListener( "change" , validateDate, false ); function validateDate(){ // Do something when the content of the 'input' element with the name 'date' is changed. } |
Although there are some browser inconsistencies with the above code,
so programmers usually go with a javascript library such as JQuery or
YUI to attach behavior to an element like above.
8. What is Javascript namespacing? How and where is it used?
Using global variables in Javascript is evil and a bad practice. That
being said, namespacing is used to bundle up all your functionality
using a unique name. In JavaScript, a namespace is really just an object
that you’ve attached all further methods, properties and objects. It
promotes modularity and code reuse in the application.
9. What datatypes are supported in Javascript?
Number, String, Undefined, null, Boolean
Number, String, Undefined, null, Boolean
10. What is the difference between innerHTML and append() in JavaScript?
InnerHTML is not standard, and its a String. The DOM is not, and
although innerHTML is faster and less verbose, its better to use the DOM
methods like appendChild(), firstChild.nodeValue, etc to alter
innerHTML content.
Q.When would you use var in your declaration and when you wouldn’t?
Always use var. Not using var for variable
declaration will traverse scopes all the way up till the global scope.
If variable with that name is not found it will declare it in the global
scope. Therefore not using var implicitly declares variable in the
global scope (which, let me remind you, is a bad practice).
(function() {
baz = 5;
var bar = 10;
})();
console.log(baz); // outputs 5
//console.log(bar); // error: bar is not defined
|
A common mistake is to not use var in loops which might, in some cases, bear unexpected results or pollute the global scope:
(function() {
var baz = "Hello World";
for(var bar=1; bar
|
Q.What does the attribute defer/async do when added to the script tag?
The defer attribute will cause browser to execute script after the
document has been parsed. This attribute was first implemented in
Internet Explorer 4, then added to HTML 4 and more recently HTML 5 spec.
You might not have heard of it as it has not been supported till
version 3.5 (Gecko 1.9.2). Async is another attribute that can affect
how a script is loaded and executed, here is a quote from HTML 5 spec on
how this is expected to work:
There are three possible modes that can be selected using these attributes. If theasync
attribute is present, then the script will be executed asynchronously, as soon as it is available. If theasync
attribute is not present but thedefer
attribute is present, then the script is executed when the page has finished parsing. If neither attribute is present, then the script is fetched and executed immediately, before the user agent continues parsing the page.
Note: A somewhat (but not exactly) similar defer behavior can be
achieved by placing your script tags at the end of the body tag and
that’s what is considered to be modern ‘best practice’
Q.What is the difference between == and ===? Which one would you use?
The equality (==) operator will compare for equality after doing
necessary type casting, the identity operator (===) doesn’t do any
conversions. A good practice suggested by Douglas Crockford is to always
use strict equality, couple of examples from Douglas’ book JavaScript: The Good Parts
'' == '0' // false
0 == '' // true
0 == '0' // true
false == 'false' // false
false == '0' // true
false == undefined // false
false == null // false
null == undefined // true
|
Q.How would you check if a variable is null/undefined?
//check if bar is null
bar === null
|
//check if bar is undefined
typeof bar === "undefined"
|
Q.How do you check if a variable is an object
You can use
You can use
typeof
to determine if variable is an object,
however bear in mind that null is actually an object! However null
object is ‘falsy’ thus the following will work:if(bar && typeof bar === "object") {
console.log('bar is object and is not null');
}
|
Q.Discuss scoping in JavaScript.?
JavaScript has lexical scoping based on functions but not blocks. Therefore:
//global scope
(function() {
//anonymous function scope
var foo = 1;
function bar() {
//bar function scope
var foo = 2;
}
bar();
console.log(foo); //outputs 1
if(true) {
var foo = 3; //redeclares foo
}
console.log(foo); //outputs 3
})();
|
Try it: http://jsfiddle.net/tnajdek/8y3XC/. Note: from within function scope everything in above scope(s) is available (see closures below)
Q.Explain hoisting in JavaScript.?
As some might not be familiar with the term ‘hoisting’ yet have the relevant experience this question could be asked indirectly
In JavaScript function declarations (
function foo() {}
) and variable declarations ( var bar
) are ‘hoisted’ i.e. are silently moved to the very top of the scope. Consider the following code:(function() {
console.log(bar); //returns 'undefined'
//console.log(baz) // error: baz is not defined
foo(); // outputs 'aloha' to the console
//function declaration AND its body is hoisted
function foo() {
console.log('aloha');
}
//variable declaration is hoisted but value assignment stays here
var bar = 1;
baz = 2; //defines baz in global scope
})();
|
See for yourself: http://jsfiddle.net/tnajdek/FxDrj/
What are closures?
(function() {
function foo(x) {
var baz = 3;
return function (y) {
console.log(x + y + (++baz));
}
}
var moo = foo(2); // moo is now a closure.
moo(1); // 7
moo(1); // 8!
})();
|
The inner function inside
foo
will close-over the variables of foo
before leaving creating a closure.
Q.Explain prototypal/differential inheritance.?
Conceptually this is very simple: A new object can inherit properties of an old object.
(function() {
var genericObject = {
bar : "Hello World",
get_bar : function() {
return this.bar;
}
};
var customObject = Object.create(genericObject);
customObject.bar = "Aloha folks!";
console.log(customObject.get_bar()); //outputs: "Aloha folks"
delete customObject.bar;
console.log(customObject.get_bar()); //fallbacks to the prototype's value, outputs: "Hello World"
})();
|
While JavaScript has always been a prototype-oriented language, tools to work with prototypes were somewhat missing.
Object.create
used in the code snipped above has been added in ECMAScript 5 and has not been supported prior to Firefox 4, Chrome 5, IE 9
Q.What is Strict Mode in JavaScript.?
Strict Mode has been introduced as part of ECMAScript 5 and introduces new, restricted variant of JavaScript which has following aims:
Strict Mode has been introduced as part of ECMAScript 5 and introduces new, restricted variant of JavaScript which has following aims:
- Throws errors for actions that are rather silly but previously didn’t throw an error
- Throws errors for potentially unsafe actions
- Disables functions that are poorly thought out
- Potentially code in strict mode could run faster by eliminating mistakes that would make it difficult for JavaScript engines to perform optimizations
Strict mode can be enabled for the entire source file or on per
function basis by adding a string literal “use strict” on top of the
file/function i.e.
function foo(){
"use strict";
// ... your code ...
}
Q.What are JavaScript types?
Number, String, Boolean, Function, Object, Null, Undefined.
Q.How do you convert numbers between different bases in JavaScript?
Use the parseInt() function, that takes a string as the first parameter, and the base as a second parameter. So to convert hexadecimal 3F to decimal, use parseInt ("3F", 16);
Q.What does "1"+2+3 evaluate to?
Since 1 is a string, everything is a string, so the result is 123.
Q.How about 3+5+"8"?
Since 3 and 5 are integers, this is number arithmetic, since 8 is a string, it’s concatenation, so 88 is the result.
Q.How do you submit a form using Javascript?
Use document.forms[0].submit();
Q.How do you assign object properties?
obj["age"] = 22 or obj.age = 22.
Q.What’s a way to append a value to an array?
arr[arr.length] = value;
Q.What does isNaN function do?
Return true if the argument is not a number.
Q.What’s relationship between JavaScript and ECMAScript?
ECMAScript is yet another name for JavaScript (other names include LiveScript). The current JavaScript that you see supported in browsers is ECMAScript revision 3.
Q.How to read and write a file using javascript?
I/O operations like reading or writing a file is not possible with client-side javascript.
Q.How do you convert numbers between different bases in JavaScript?
Use the parseInt() function, that takes a string as the first parameter, and the base as a second parameter. So to convert hexadecimal FF to decimal, use parseInt ("FF", 16);
Q.What is negative infinity?
It’s a number in JavaScript, derived by dividing negative number by zero.
Q.How to set a HTML document's background color?
document.bgcolor property can be set to any appropriate color.
Q.What boolean operators does JavaScript support?
&&, and !
Q.How to get the contents of an input box using Javascript?
Use the "value" property.
var myValue = window.document.getElementById("textboxID").value;
Q.How to determine the state of a checkbox using Javascript?
var checkedP = window.document.getElementById("CheckBoxID").checked;
Q.How to set the focus in an element using Javascript?
<script> function setFocus() { if(focusElement != null) { document.forms[0].elements["myelementname"].focus(); } } </script>
Q.How to access an external javascript file that is stored externally and not embedded?
This can be achieved by using the following tag between head tags or between body tags.
<script src="raj.js"></script>How to access an external javascript file that is stored externally and not embedded? where abc.js is the external javscript file to be accessed.
Q.What is the difference between an alert box and a confirmation box?
An alert box displays only one button which is the OK button whereas the Confirm box displays two buttons namely OK and cancel.
Q.What is a prompt box?
A prompt box allows the user to enter input by providing a text box.
Q.Can javascript code be broken in different lines?
Breaking is possible within a string statement by using a backslash \ at the end but not within any other javascript statement.
that is ,
document.write("Hello \ world");
is possible but not document.write \
("hello world");
Q.What looping structures are there in JavaScript?
for, while, do-while loops, but no foreach.
Q.How do you create a new object in JavaScript?
var obj = new Object(); or var obj = {};
Q.What is this keyword?
It refers to the current object.
Q.What is the difference between SessionState and ViewState?
ViewState is specific to a page in a session. Session state refers to user specific data that can be accessed across all pages in the web application.
Q.What looping structures are there in JavaScript?
for, while, do-while loops, but no foreach.
Q.To put a "close window" link on a page ?
<a href='javascript:window.close()' class='mainnav'> Close </a>
Q.How to hide javascript code from old browsers that dont run it?
Use the below specified style of comments <script language=javascript> <!-- javascript code goes here // --> or Use the <NOSCRIPT>some html code </NOSCRIPT> tags and code the display html statements between these and this will appear on the page if the browser does not support javascript
Q.How to comment javascript code?
Use // for line comments and
/*
*/ for block comments
Q.Name the numeric constants representing max,min values
Number.MAX_VALUE
Number.MIN_VALUE
Q.What does javascript null mean?
The null value is a unique value representing no value or no object.
It implies no object,or null string,no valid boolean value,no number and no array object.
Q.How do you create a new object in JavaScript?
var obj = new Object(); or var obj = {};
Q.How do you assign object properties?
obj["age"] = 23 or obj.age = 23.
Q.What’s a way to append a value to an array?
arr[arr.length] = value;
Q.To set all checkboxes to true using JavaScript?
//select all input tags
function SelectAll() {
var checkboxes = document.getElementsByTagName("input");
for(i=0;i<checkboxes.length;i++) {
if(checkboxes.item(i).attributes["type"].value == "checkbox") {
checkboxes.item(i).checked = true;
}
}
}
Q.What does undefined value mean in javascript?
Undefined value means the variable used in the code doesn't exist or is not assigned any value or the property doesn't exist.
Q.What is the difference between undefined value and null value?
(i)Undefined value cannot be explicitly stated that is there is no keyword called undefined whereas null value has keyword called null
(ii)typeof undefined variable or property returns undefined whereas typeof null value returns object
Q.What is variable typing in javascript?
It is perfectly legal to assign a number to a variable and then assign a string to the same variable as follows
example
i = 10;
i = "string";
This is called variable typing
Q.Does javascript have the concept level scope?
No. JavaScript does not have block level scope, all the variables declared inside a function possess the same level of scope unlike c,c++,java.
Q.What are undefined and undeclared variables?
Undeclared variables are those that are not declared in the program (do not exist at all),trying to read their values gives runtime error.But if undeclared variables are assigned then implicit declaration is done .
Undefined variables are those that are not assigned any value but are declared in the program.Trying to read such variables gives special value called undefined value.
Q.What is === operator ?
==== is strict equality operator ,it returns true only when the two operands are having the same value without any type conversion.
Q.How to disable an HTML object ?
document.getElementById("myObject").disabled = true;
How to create a popup warning box?
alert('Warning: Please enter an integer between 0 and 1000.');
Q.How to create a confirmation box?
confirm("Do you really want to launch the missile?");
Q.How to create an input box?
prompt("What is your temperature?");
Q.How to force a page to go to another page using JavaScript ?
<script language="JavaScript" type="text/javascript" ><!-- location.href="http://rajeshstutorials.blogspt.com"; //--></script>
Q.What's Math Constants and Functions using JavaScript?
The Math object contains useful constants such as Math.PI, Math.E
Math.abs(value); //absolute value
Math.max(value1, value2); //find the largest
Math.random() //generate a decimal number between 0 and 1
Math.floor(Math.random()*101) //generate a decimal number between 0 and 100
Q.What does the delete operator do?
The delete operator is used to delete all the variables and objects used in the program ,but it does not delete variables declared with var keyword.
Q.How to get value from a textbox?
alert(document.getElementById('txtbox1').value);
Q.How to get value from dropdown (select) control?
alert(document.getElementById('dropdown1').value);
Number, String, Boolean, Function, Object, Null, Undefined.
Q.How do you convert numbers between different bases in JavaScript?
Use the parseInt() function, that takes a string as the first parameter, and the base as a second parameter. So to convert hexadecimal 3F to decimal, use parseInt ("3F", 16);
Q.What does "1"+2+3 evaluate to?
Since 1 is a string, everything is a string, so the result is 123.
Q.How about 3+5+"8"?
Since 3 and 5 are integers, this is number arithmetic, since 8 is a string, it’s concatenation, so 88 is the result.
Q.How do you submit a form using Javascript?
Use document.forms[0].submit();
Q.How do you assign object properties?
obj["age"] = 22 or obj.age = 22.
Q.What’s a way to append a value to an array?
arr[arr.length] = value;
Q.What does isNaN function do?
Return true if the argument is not a number.
Q.What’s relationship between JavaScript and ECMAScript?
ECMAScript is yet another name for JavaScript (other names include LiveScript). The current JavaScript that you see supported in browsers is ECMAScript revision 3.
Q.How to read and write a file using javascript?
I/O operations like reading or writing a file is not possible with client-side javascript.
Q.How do you convert numbers between different bases in JavaScript?
Use the parseInt() function, that takes a string as the first parameter, and the base as a second parameter. So to convert hexadecimal FF to decimal, use parseInt ("FF", 16);
Q.What is negative infinity?
It’s a number in JavaScript, derived by dividing negative number by zero.
Q.How to set a HTML document's background color?
document.bgcolor property can be set to any appropriate color.
Q.What boolean operators does JavaScript support?
&&, and !
Q.How to get the contents of an input box using Javascript?
Use the "value" property.
var myValue = window.document.getElementById("textboxID").value;
Q.How to determine the state of a checkbox using Javascript?
var checkedP = window.document.getElementById("CheckBoxID").checked;
Q.How to set the focus in an element using Javascript?
<script> function setFocus() { if(focusElement != null) { document.forms[0].elements["myelementname"].focus(); } } </script>
Q.How to access an external javascript file that is stored externally and not embedded?
This can be achieved by using the following tag between head tags or between body tags.
<script src="raj.js"></script>How to access an external javascript file that is stored externally and not embedded? where abc.js is the external javscript file to be accessed.
Q.What is the difference between an alert box and a confirmation box?
An alert box displays only one button which is the OK button whereas the Confirm box displays two buttons namely OK and cancel.
Q.What is a prompt box?
A prompt box allows the user to enter input by providing a text box.
Q.Can javascript code be broken in different lines?
Breaking is possible within a string statement by using a backslash \ at the end but not within any other javascript statement.
that is ,
document.write("Hello \ world");
is possible but not document.write \
("hello world");
Q.What looping structures are there in JavaScript?
for, while, do-while loops, but no foreach.
Q.How do you create a new object in JavaScript?
var obj = new Object(); or var obj = {};
Q.What is this keyword?
It refers to the current object.
Q.What is the difference between SessionState and ViewState?
ViewState is specific to a page in a session. Session state refers to user specific data that can be accessed across all pages in the web application.
Q.What looping structures are there in JavaScript?
for, while, do-while loops, but no foreach.
Q.To put a "close window" link on a page ?
<a href='javascript:window.close()' class='mainnav'> Close </a>
Q.How to hide javascript code from old browsers that dont run it?
Use the below specified style of comments <script language=javascript> <!-- javascript code goes here // --> or Use the <NOSCRIPT>some html code </NOSCRIPT> tags and code the display html statements between these and this will appear on the page if the browser does not support javascript
Q.How to comment javascript code?
Use // for line comments and
/*
*/ for block comments
Q.Name the numeric constants representing max,min values
Number.MAX_VALUE
Number.MIN_VALUE
Q.What does javascript null mean?
The null value is a unique value representing no value or no object.
It implies no object,or null string,no valid boolean value,no number and no array object.
Q.How do you create a new object in JavaScript?
var obj = new Object(); or var obj = {};
Q.How do you assign object properties?
obj["age"] = 23 or obj.age = 23.
Q.What’s a way to append a value to an array?
arr[arr.length] = value;
Q.To set all checkboxes to true using JavaScript?
//select all input tags
function SelectAll() {
var checkboxes = document.getElementsByTagName("input");
for(i=0;i<checkboxes.length;i++) {
if(checkboxes.item(i).attributes["type"].value == "checkbox") {
checkboxes.item(i).checked = true;
}
}
}
Q.What does undefined value mean in javascript?
Undefined value means the variable used in the code doesn't exist or is not assigned any value or the property doesn't exist.
Q.What is the difference between undefined value and null value?
(i)Undefined value cannot be explicitly stated that is there is no keyword called undefined whereas null value has keyword called null
(ii)typeof undefined variable or property returns undefined whereas typeof null value returns object
Q.What is variable typing in javascript?
It is perfectly legal to assign a number to a variable and then assign a string to the same variable as follows
example
i = 10;
i = "string";
This is called variable typing
Q.Does javascript have the concept level scope?
No. JavaScript does not have block level scope, all the variables declared inside a function possess the same level of scope unlike c,c++,java.
Q.What are undefined and undeclared variables?
Undeclared variables are those that are not declared in the program (do not exist at all),trying to read their values gives runtime error.But if undeclared variables are assigned then implicit declaration is done .
Undefined variables are those that are not assigned any value but are declared in the program.Trying to read such variables gives special value called undefined value.
Q.What is === operator ?
==== is strict equality operator ,it returns true only when the two operands are having the same value without any type conversion.
Q.How to disable an HTML object ?
document.getElementById("myObject").disabled = true;
How to create a popup warning box?
alert('Warning: Please enter an integer between 0 and 1000.');
Q.How to create a confirmation box?
confirm("Do you really want to launch the missile?");
Q.How to create an input box?
prompt("What is your temperature?");
Q.How to force a page to go to another page using JavaScript ?
<script language="JavaScript" type="text/javascript" ><!-- location.href="http://rajeshstutorials.blogspt.com"; //--></script>
Q.What's Math Constants and Functions using JavaScript?
The Math object contains useful constants such as Math.PI, Math.E
Math.abs(value); //absolute value
Math.max(value1, value2); //find the largest
Math.random() //generate a decimal number between 0 and 1
Math.floor(Math.random()*101) //generate a decimal number between 0 and 100
Q.What does the delete operator do?
The delete operator is used to delete all the variables and objects used in the program ,but it does not delete variables declared with var keyword.
Q.How to get value from a textbox?
alert(document.getElementById('txtbox1').value);
Q.How to get value from dropdown (select) control?
alert(document.getElementById('dropdown1').value);
Q: How do you implement an extend function that takes an object and extends itwith new properties and makes it work on n levels of recursion? Basically, duplicating a jQuery extend.
This question shows whether candidates have an understanding of basic
programming concepts such as recursion, says Jonas Huckestein,
co-founder of conference-calling startup HipDial.
Q: Can you write a function that takes an object and appends
it to the DOM, making it so that events are buffered until the next
tick? Explain why this is useful?
This last part only applies in browser-side settings where it can dramatically increase performance, he says.
Q: How do you write an event emitter base class that allows you to add event listeners?
This question can nicely lead into architectural questions,
Huckestein says, such as: “How would you make an event emitter that’s
distributed?”
Q: What is the concept of “functions as objects” and how does this affect variable scope?
New hires at Vector Media Group are asked this mid-level question,
says Matt Weinberg, president of development and technology at Vector, a
web development and Internet marketing agency in Manhattan.
“What it can suggest is that the person really ‘gets’ JavaScript and
the way it works as opposed to just having copied syntax and code from
the web without understanding it,” Weinberg says. “It can also show that
the person has at least some understanding of basic programming
concepts, which in my experience means they will be better equipped to
come up with good solutions to hard problems.”
Q: What modern JavaScript frameworks and utilities excite you
right now from an approach and code point of view, even if they’re not
yet stable enough for client work?
“I’m less concerned with the actual answers, though there are some
frameworks I’m very interested in,” Weinberg says. “[I’m] more concerned
with knowing that they keep up to date on the latest thinking around
JavaScript.”
Weinberg added: “When they explain what excites them about these
frameworks or utilities, I can get a good sense of the kind of work and
style they prefer.”
Kubasik is also concerned about the flood of “copy-and-paste” JavaScript solutions.
“jQuery and its plugin system are so popular that many developers
only know JavaScript in that context, and have trouble understanding how
to create new functionality,” Kubasik says. “While this is fine for
many websites, which only need a dynamic menu or homepage carousel, as
the emerging web becomes more “stateful” – (he points to USA Today’s
redesign as an example of pages that users navigate without loading a
new page) – this knowledge becomes crucial to developing robust and
maintainable applications.”
Q: What is the difference between .call() and .apply()?
The JavaScript Function prototype has two very powerful functions
that are at the core of Javascript’s “everything is an object”
mentality, including functions, Kubasik says.
“The really important part of this discussion is not that they
remember which is which, but more that the interviewee understands that
the “this” keyword is not as predictable as in other languages, and that
functions can be applied to other objects, and generally be treated as
data,” he says.
Q: Can you explain how inheritance works in JavaScript?
JavaScript has a somewhat unique inheritance model and a good
understanding of it is crucial to using JavasScript in larger
applications, Kubasik says. “We are looking for the applicant to
discuss not only prototypes, and how that affects inheritance, but in
what ways this can be more flexible than classical inheritance models
seen in Java and C#.”
Q: What is event bubbling in the DOM?
The main goal of this question is to establish that the applicant
knows what order events will be propagated in the DOM – most specific to
least specific.
“Not everyone may know this by the name ‘event bubbling,’ so asking
about event propagation in general is sometimes needed. Ideally, this is
an opportunity to discuss event models outside of the DOM, and ask
follow-up questions about routing based on user actions, looking for
techniques popularized with frameworks like backbone.js, or AngularJS,”
Kubasik says.
Blake Haggerty, Rackspace’s lead recruiter in San Francisco, says
that beyond specific questions, recruiters have other resources for
assessing candidates’ skills with JavaScript.
“I can go onto GitHub or BitBucket. I can actually look at what
they’ve done with their code. I can see the projects they’ve worked on
[and] I can see how much they’ve contributed to projects. I can go onto
sites like Stack Overflow and see who are the influential people in the
community, see who’s answering questions specifically about JavaScript,”
he says. “… from that I already know they’re technically savvy, so from
there, my role is just to convince them to leave where they currently
are and come work for us.”
Q.How to get value from a textbox?alert(document.getElementById('txtbox1').value); |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Q.How to get value from dropdown (select) control.?alert(document.getElementById('dropdown1').value); |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Q.How to get value from RadioButtonList control?
Here id is the name property of the RadioButtonList
function GetRadioButtonValue(id)
{
var radio = document.getElementsByName(id);
for (var ii = 0; ii < radio.length; ii++)
{
if (radio[ii].checked)
alert(radio[ii].value);
}
}
For more details, click http://www.dotnetfunda.com/articles/article72.aspx |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Q.How to get CheckBox status whether it is checked or not?
Write following code
alert(document.getElementById('checkbox1').checked); if it will be checked you will get true else false. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Q.How to toggle display an HTML element?Call following functionfunction ToggleFollowingText(id)
{
document.getElementById(id).style.display == '' ? document.getElementById(id).style.display =
'none' : document.getElementById(id).style.display = '';
}
In above function you need to pass id of the html element as the parameter.
If the control is already displaying then it will hide otherwise it will be shown.
Q.How Will You Get Textbox Value in Javascript?
By Using This javascript Code ,We Can Get The Textbox Value...
var txt_value= document.getElementById('<%=TextBox1.ClientID%>').value;
|
In the answer for appending in an array wouldn't array.push be better than the answer given....
ReplyDelete