What is the difference between delete obj.property and obj.property = undefined?
delete obj.property
obj.property = undefined
They are functionally the same.
You cannot set a property to undefined in JavaScript.
undefined
delete sets the property to null, while setting it to undefined removes it entirely.
delete
null
delete completely removes the property, while setting it to undefined keeps the property but with no value.
What will be the output of the following code?
let i = 0; while (i < 5) { console.log(i); i++; }
1 2 3 4
0 1 2 3 4 5
1 2 3 4 5
0 1 2 3 4
Which of the following is NOT a feature of JavaScript?
Interpreted language
Object-oriented programming capabilities
Client-side scripting language
Strongly typed language
Which of these is a valid way to embed JavaScript in an HTML file?
<js> alert('Hello!'); </js>
<javascript> alert('Hello!'); </javascript>
Which of the following is NOT a built-in function in JavaScript for interacting with the user through the browser?
console.log()
confirm()
prompt()
alert()
What is the correct way to add an event listener that logs 'Button Clicked!' to the console when a button with the ID 'myButton' is clicked?
document.getElementById('myButton').addEventListener('click', console.log('Button Clicked!'));
document.querySelector('#myButton').onclick = console.log('Button Clicked!');
document.getElementById('myButton').addEventListener('click', function() { console.log('Button Clicked!'); });
document.querySelector('#myButton').addEventListener('click', () => console.log('Button Clicked!'));
Which event is fired when a user clicks on an HTML element?
onload
onclick
onmouseover
onmousedown
How many times will the following loop iterate?
for (let i = 1; i <= 10; i += 2) { console.log(i); }
5
infinite
10
6
What will the browser display after running this JavaScript code: alert('Hello') + ' World!'; ?
alert('Hello') + ' World!';
Hello World!
An error message
Hello
World!
What is the result of the expression: 10 % 3?
10 % 3
0
1
3