| JavaScript question answers 1-20 :👈 | 👉:JavaScript question answers 41-60 |
JavaScript Question Answers - 21-40 |
21. Write about the errors shown in JavaScript
- 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.
22. Between JavaScript and an ASP script, which is faster
JavaScript is faster because it runs on the client-side, while ASP executes on the server-side.
23. What is namespacing in JavaScript and how is it used
Namespacing groups related functions, variables, and objects under a unique name to avoid conflicts. Example:
var MyApp = { utils: { log: function(msg){ console.log(msg); } } };
24. What is negative infinity
Negative Infinity is a special numeric value in JavaScript, returned when a negative number is divided by zero. Example: -1/0.
25. Which company developed JavaScript
Netscape developed JavaScript in 1995.
26. Whether JavaScript has concept level scope
No, JavaScript has function-level scope (and block scope with let and const), but not concept-level scope.
27. How are object properties assigned
Object properties are assigned like variables. Example: obj.name = "John";
28. What would be the result of 3+2+”7″
The result is "57". Numbers are added first (3+2=5), then concatenated with the string "7".
29. What boolean operators can be used in JavaScript
JavaScript supports:
- && (AND)
- || (OR)
- ! (NOT)
30. How to find operating system in the client machine using JavaScript
You can use navigator.appVersion or navigator.userAgent to detect the client’s operating system.
31. How can a page be forced to load another page in JavaScript
Use window.location = "newpage.html"; or window.location.href = "newpage.html";.
32. Explain the for-in loop
The for-in loop iterates over the enumerable properties of an object. Example:
for (var key in obj) { console.log(key + ":" + obj[key]); }
33. What is the function of delete operator
The delete operator removes a property from an object. Example: delete obj.name;
34. How can the OS of the client machine be detected
By checking navigator.appVersion or navigator.platform.
35. What do mean by NULL in JavaScript
null is a special value representing “no value” or “empty object reference.”
36. Explain window.onload and onDocumentReady
- 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.
37. Explain what is pop() method in JavaScript
The pop() method removes and returns the last element of an array.
38. What is the use of Push method in JavaScript
The push() method adds one or more elements to the end of an array and returns the new length.
39. What is the way to get the status of a CheckBox
Use the checked property: document.getElementById("myCheck").checked;
40. How can a particular frame be targeted, from a hyperlink, in JavaScript
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 |