JavaScript Web Development Theory Questions
JavaScript Web Development Theory Questions
The open() method is used to open a new browser window or tab. Syntax: `window.open(URL,
name, specs, replace)`. The URL specifies the page to open, name sets the window's target, specs
define window features like height, width, etc., and replace specifies if the URL will replace the
A session cookie is a type of cookie that is stored temporarily in a browser's memory while the user
is browsing. Once the user closes the browser, the session cookie is deleted. It's used for keeping
`g` flag stands for global search, `m` flag is for multiline search, and `i` flag is for case-insensitive
search. Example: `/hello/gi` will match all instances of 'hello' in any case within a text.
Quantifiers in regex are symbols that define the number of occurrences. `*` matches zero or more,
`+` matches one or more, and `{n,m}` matches between n and m times. Example: `/a{2,3}/` matches
'aa' or 'aaa'.
`childWindow.document.getElementById('elementID')`.
A floating menu stays visible on the screen as the user scrolls. Example: CSS with `position: fixed;`
keeps the menu fixed in place.
7) Give syntax and explain the use of setTimeout() function with example.
milliseconds)`. Example: `setTimeout(() => alert('Hello'), 2000);` shows an alert after 2 seconds.
Four mouse events: `click` - triggered when an element is clicked, `mouseover` - triggered when
mouse hovers over, `mouseout` - triggered when mouse leaves, `dblclick` - triggered on
double-clicking an element.
```javascript
`test()` checks if a pattern exists, returning true/false. `exec()` returns matched content if found or
Menu validation ensures the user selects a valid option. Example: use `if (dropdown.value ===
Use an array to store image URLs and `setInterval()` to display them with next/previous buttons.
13) JavaScript to search for 'MSBTE' in a string.
```javascript
if (/MSBTE/.test(text)) {
console.log('Pattern is found');
} else {
```
```javascript
function storeCookie() {
```
```javascript
if (/\d{12}/.test(aadhaarInput.value)) {
console.log('Valid');
} else {
console.log('Invalid');
```
Regex is a pattern for text matching. Example: `/\d/` matches any digit.