| Connecting JS with REST APIs :👈 | 👉:JavaScript question answers 21-40 |
JavaScript Question Answers - 1 - 20 |
1. How can a value be appended to an array
A value can be appended using push() or arr[arr.length] = value;
2. How are object properties assigned
Object properties are assigned like variables. Example: obj.name = "John";
3. What is the use of blur function
The blur() function removes focus from an element.
4. What is the difference between JavaScript and Jscript
JavaScript was developed by Netscape, JScript by Microsoft. Both are very similar.
5. Write the point of difference between web-garden and a web-farm
- Web-garden: multiple processors in one server.
- Web-farm: multiple servers working together.
6. What is break and continue statements
- break: exits a loop.
- continue: skips current iteration.
7. What is the role of break and continue statements
break exits a loop entirely, continue skips to the next iteration.
8. Is it possible to break JavaScript Code into several lines
Yes. Use \\ inside strings, or line breaks outside strings are ignored.
9. Explain the role of deferred scripts in JavaScript
defer delays script execution until HTML parsing is complete, improving performance.
10. What are JavaScript Cookies
Cookies are small text files stored on the client to save user data like login info or cart items.
11. Which keyword is used to print the text in the screen
document.write("text")
12. How are DOM utilized in JavaScript
The DOM represents the page structure; JavaScript manipulates it to change content, style, or structure.
13. How are JavaScript and ECMA Script related
ECMAScript is the standardized specification; JavaScript is its implementation.
14. How are event handlers utilized in JavaScript
Event handlers respond to user actions. Example: element.onclick = function() {...}
15. Mention what is the disadvantage of using innerHTML in JavaScript
- Replaces all content
- Slower (re-parses DOM)
- Removes event handlers
- Can insert unsafe HTML
16. Explain how to detect the operating system on the client machine
Use navigator.appVersion or navigator.userAgent.
17. What is the use of isNaN function
isNaN() checks if a value is not a number.
18. How can the style/class of an element be changed
document.getElementById("id").style.color = "red";
document.getElementById("id").className = "newClass";
19. Enumerate the differences between Java and JavaScript
- Java: compiled, strongly typed, OOP language.
- JavaScript: interpreted, loosely typed, scripting language.
20. Define event bubbling
Event bubbling is when an event on a child element propagates up to its parent elements.
| Connecting JS with REST APIs :👈 | 👉:JavaScript question answers 21-40 |