MSBTE JS Questions Answers
MSBTE JS Questions Answers
| Operator | Meaning |
|----------|------------------------|
|| | Bitwise OR |
|^ | Bitwise XOR |
|~ | Bitwise NOT |
do {
// Code to be executed
} while (condition);
<!DOCTYPE html>
<html>
<head>
<title>External JS Example</title>
<script src="script.js"></script>
</head>
<body>
<h1>Hello from HTML</h1>
</body>
</html>
arr.push(4, 5);
console.log(arr); // [1, 2, 3, 4, 5]
|--------------|-----------------------------|-------------------------------|
| Attribute | Significance |
|----------|----------------------------------|
setInterval(function, milliseconds);
switch(expression) {
case value1:
// code
break;
case value2:
// code
break;
default:
// code
Example:
let day = 3;
switch(day) {
firstName: "John",
lastName: "Doe",
set fullName(name) {
this.firstName = parts[0];
this.lastName = parts[1];
};
console.log(person.fullName);
console.log(person.fullName);
let num = 7;
else {
parseInt("123.45"); // 123
parseFloat("123.45"); // 123.45
+"456"; // 456
"A".charCodeAt(0); // 65
String.fromCharCode(65); // "A"
console.log(result); // 15
d) Features of JavaScript:
1. Lightweight
2. Interpreted
3. Object-Based
4. Event-Driven
5. Platform Independent
6. Dynamic Typing
7. Functional Support
8. Browser Control
Example:
1. React.js ? UI library
document.addEventListener("contextmenu", function(e){
e.preventDefault();
alert("Right-click disabled!");
});
d) Call a function in child window.
Parent (index.html):
Child (child.html):
function childFunction() {
- Disable right-click
- Email obfuscation
- Use CAPTCHA
- JavaScript obfuscation
<script>
document.write("<a href='mailto:" + user + "@" + domain + "'>" + user + "@" + domain + "</a>");
</script>