| JavaScript Home Page | JavaScript question answers 21-40 | |
JavaScript Question Answers - 1 - 20 |
A value can be appended using push() or arr[arr.length] = value;
Object properties are assigned like variables. Example: obj.name = "John";
The blur() function removes focus from an element.
JavaScript was developed by Netscape, JScript by Microsoft. Both are very similar.
- Web-garden: multiple processors in one server.
- Web-farm: multiple servers working together.
- break: exits a loop.
- continue: skips current iteration.
break exits a loop entirely, continue skips to the next iteration.
Yes. Use \\ inside strings, or line breaks outside strings are ignored.
defer delays script execution until HTML parsing is complete, improving performance.
Cookies are small text files stored on the client to save user data like login info or cart items.
document.write("text")
The DOM represents the page structure; JavaScript manipulates it to change content, style, or structure.
ECMAScript is the standardized specification; JavaScript is its implementation.
Event handlers respond to user actions. Example: element.onclick = function() {...}
- Replaces all content
- Slower (re-parses DOM)
- Removes event handlers
- Can insert unsafe HTML
Use navigator.appVersion or navigator.userAgent.
isNaN() checks if a value is not a number.
document.getElementById("id").style.color = "red";
document.getElementById("id").className = "newClass";
- Java: compiled, strongly typed, OOP language.
- JavaScript: interpreted, loosely typed, scripting language.
Event bubbling is when an event on a child element propagates up to its parent elements.
| JavaScript Home Page | JavaScript question answers 21-40 | |