| JavaScript question answers 1-20 | JavaScript question answers 41-60 | |
JavaScript Question Answers - 21-40 |
- Load-time errors: occur during page load due to syntax issues.
- Run-time errors: occur while executing code.
- Logic errors: code runs but produces incorrect results.
JavaScript is faster because it runs on the client-side, while ASP executes on the server-side.
Namespacing groups related functions, variables, and objects under a unique name to avoid conflicts. Example:
var MyApp = { utils: { log: function(msg){ console.log(msg); } } };
Negative Infinity is a special numeric value in JavaScript, returned when a negative number is divided by zero. Example: -1/0.
Netscape developed JavaScript in 1995.
No, JavaScript has function-level scope (and block scope with let and const), but not concept-level scope.
Object properties are assigned like variables. Example: obj.name = "John";
The result is "57". Numbers are added first (3+2=5), then concatenated with the string "7".
JavaScript supports:
- && (AND)
- || (OR)
- ! (NOT)
You can use navigator.appVersion or navigator.userAgent to detect the client’s operating system.
Use window.location = "newpage.html"; or window.location.href = "newpage.html";.
The for-in loop iterates over the enumerable properties of an object. Example:
for (var key in obj) { console.log(key + ":" + obj[key]); }
The delete operator removes a property from an object. Example: delete obj.name;
By checking navigator.appVersion or navigator.platform.
null is a special value representing “no value” or “empty object reference.”
- window.onload: Executes after the entire page (including images, scripts, etc.) is fully loaded.
- onDocumentReady: Executes once the DOM is ready, without waiting for images or other resources.
The pop() method removes and returns the last element of an array.
The push() method adds one or more elements to the end of an array and returns the new length.
Use the checked property: document.getElementById("myCheck").checked;
By using the target attribute of the hyperlink. Example: <a href="page.html" target="frameName">
| JavaScript question answers 1-20 | JavaScript question answers 41-60 | |