| JavaScript question answers 21-40 | JavaScript question answers 61-80 | |
JavaScript Question Answers - 41-60 |
In browsers, direct file access is restricted. Use the File API for reading and downloads/server APIs for writing. In Node.js, use fs.readFile() and fs.writeFile().
Use document.forms["formName"].submit(); or document.getElementById("formId").submit();
- Undeclared: Variables not declared with var, let, or const.
- Undefined: Variables declared but not assigned a value.
It means a variable has been declared but not assigned any value.
arr.unshift() adds one or more elements to the beginning of an array and returns the new length.
Yes, JavaScript performs implicit type conversion (type coercion) when required.
Timers are created using setTimeout() (executes once after delay) and setInterval() (executes repeatedly). They can be cleared with clearTimeout() and clearInterval().
Variables declared outside any function or without var/let/const become global and accessible throughout the script.
&& (AND), || (OR), ! (NOT)
- Single-line: // comment
- Multi-line: /* comment */
this refers to the current execution context (the object that owns the function being executed).
typeof returns the type of a variable or expression. Example: typeof "hello" → "string".
- ViewState: Maintains state of a page within the client (specific to ASP.NET).
- SessionState: Maintains state across multiple pages on the server side.
- ==: Compares values after type conversion (loose equality).
- ===: Compares both value and type (strict equality).
Example:
var para = document.createElement("p");
para.textContent = "New Paragraph";
document.body.appendChild(para);
The === operator checks both value and type equality (strict equality).
- Functions without a name.
- Often assigned to variables or used as callbacks.
- Cannot be referenced by name.
- Example: var f = function(x){ return x*x; };
A prompt box is used to take input from the user. Example: var name = prompt("Enter your name:");
Math.abs(x)
Math.acos(x)
| JavaScript question answers 21-40 | JavaScript question answers 61-80 | |