JavaScript

  Home  World Wide Web  JavaScript


“JavaScript Tutorial with interview questions and answers. And thousands of JavaScript real Examples.”



114 JavaScript Questions And Answers

45⟩ 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");

 194 views

46⟩ Taking a developer’s perspective, do you think that that JavaScript is easy to learn and use?

One of the reasons JavaScript has the word "script" in it is that as a programming language, the vocabulary of the core language is compact compared to full-fledged programming languages. If you already program in Java or C, you actually have to unlearn some concepts that had been beaten into you. For example, JavaScript is a loosely typed language, which means that a variable doesn't care if it's holding a string, a number, or a reference to an object; the same variable can even change what type of data it holds while a script runs.

The other part of JavaScript implementation in browsers that makes it easier to learn is that most of the objects you script are pre-defined for the author, and they largely represent physical things you can see on a page: a text box, an image, and so on. It's easier to say, "OK, these are the things I'm working with and I'll use scripting to make them do such and such," instead of having to dream up the user interface, conceive of and code objects, and handle the interaction between objects and users. With scripting, you tend to write a _lot_ less code.

 230 views

48⟩ 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.

 213 views

50⟩ What does the EnableViewStateMac setting in an aspx page do?

Setting EnableViewStateMac=true is a security measure that allows ASP. NET to ensure that the viewstate for a page has not been tampered with. If on Postback, the ASP. NET framework detects that there has been a change in the value of viewstate that was sent to the browser, it raises an error - Validation of viewstate MAC failed.

Use <%@ Page EnableViewStateMac="true"%> to set it to true (the default value, if this attribute is not specified is also true) in an aspx page.

 204 views

53⟩ How to hide JavaScript code from old browsers that don't 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

 218 views

54⟩ How to comment JavaScript code?

Use // for a single line comments in JavaScript and

/* start of Multiple lines comment in JavaScript

Multiple line comments in JavaScript

*/ for block comments in JavaScript

 188 views

56⟩ 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.

 202 views