Answer these 1000+ JavaScript MCQs and assess your grip on the subject of JavaScript. Scroll below and get started!
A. subjective
B. evil
C. object based
D. objective
A. Math.PI.toString("D2")
B. Math.PI.toFixed(2)
C. Math.Round(Math.PI)
D. Math.PI.toPrecision(2)
A. Error: type mismatch
B. true
C. false
A. obj["age"] = 25 OR obj.age = 25
B. obj.age = 25 OR obj(@"age") = 25
C. obj(age) = 25 OR obj.age = 25
A. true
B. null
C. false
D. Throws Error, invalid comparison
A. a random number that can be any value
B. a random number between 0 and 100
C. a random number between 0 and 1
D. a random number between 0 and 1000
A. true
B. undefined
C. NaN
D. "!!foo"
A. var obj = new Object();
B. var obj = {};
C. function Foo() {} var obj = new Foo();
D. All of these work.
A. an underscore "_"
B. a colon ":"
C. a full-stop "."
D. a semicolon ";"
E. a comma ","
A. false
B. true
C. "B"
D. "A"
E. undefined
A. &
B. &&
C. ||
D. !
A. Math.ceil(x, y)
B. max(x, y)
C. top(x, y)
D. Math.max(x, y)
E. ceil(x, y)
A. A !== B
B. A !== B && B !== C && A !== C
C. A !== B & B !== C
D. A !== B || B !== C
A. The code inside a while loop will always be executed at least once, even if the condition is false.
B. The code inside a do...while loop will always be executed at least once, even if the condition is false.
C. There is no difference between them.
A. myArr.unshift();
B. myArr[0];
C. myArr.shift();
D. myArr[1];
E. myArr.pop();
A. while (...) { }
B. do { } while(...)
C. for (...) { }
D. repeat (...) { }
A. / This comment has more than one line /
B. // This comment has more than one line //
C. /* This comment has more than one line */
D. // This comment has mor than one line *//
A. To add a value to an array.
B. To delete a (global) variable.
C. To terminate an Object statement.
D. To divide (or "break") a mathematical value in half.
E. To terminate a switch statement, loop, or labeled block.
A. 100
B. $
C. 0
D. -1
E. 1
A. ++x is depreciated and replaced with x++;
B. x++ will return the value of x and then increment, where as ++x will increment the variable first then return its value.
C. They both do the same thing, just different syntax
A. Declare a member of a class
B. Change a constant
C. Create a new local variable
D. Retrieve a variable descriptor
A. number
B. All of these
C. string
D. boolean
A. for (var i=0; i < myArray.length; i++)
B. for (i = 0; i <= myArray.length;)
C. for (i < myArray.length; i++)
A. Return any number
B. Return a number raised to the power of a second number
C. Return a random value between 0 and 1
D. Return a variable value
A. 2
B. 3
C. 4
A. Math.round(7.25)
B. round(7.25)
C. Math.rnd(7.25)
D. rnd(7.25)
A. Yes
B. No
A. Just double quotes: "example"
B. Just single quotes: 'example'
C. Either double quotes or single quotes: "example" and 'example'
A. function myFunc(arg1, arg2):
B. func myFunc = (arg1 as string, arg2 as int) { }
C. function myFunc(arg1,arg2) { }
A. true
B. false
A. x.__type;
B. typeof(x);
C. Object.type(x);
D. gettype(x);
A. Cancels the current event.
B. Aborts the current loop or switch statement.
C. Aborts the current function.
D. Simulates a JavaScript crash.
A. An error is thrown because of illegal out of scope access.
B. "foo + bar"
C. NaN
D. "foobar"
E. "undefinedundefined"
A. var names = array("Tim", "Kim", "Jim");
B. var names = {1: "Tim", 2:"Kim", 3:"Jim"};
C. var names = {0: "Tim", 1: "Kim", 2: "Jim"};
D. var names = ["Tim","Kim","Jim"];
A. // comment
B. \\ comment
C.
D. -- comment
E. # comment
A. new fName = { }
B. func fName = function () {}
C. None of these
D. function fName() { }
E. function fName: { }
A. ||
B. &&
C. %
D. !
A. string myVar = "This is a string";
B. var myVar = "This is a string";
C. var string myVar = "This is a string";
A. throw
B. program
C. void
D. return
A. new john = Person('John', 'Doe', 50, 'blue');
B. var Person john = new Person('John', 'Doe', 50, 'blue');
C. var john = new Person('John', 'Doe', 50, 'blue');
D. Person john = new Person('John', 'Doe', 50, 'blue');
A. if (x = 1) { }
B. if (x ==== 1) { }
C. if (x === 1) { }
D. if (x == 1) { }
A. 5
B. 2
C. 24
D. Other/Error
A. +
B. &
C. All of these
D. .
A. Strongly typed, variables are declared with a type, and you can not assign another type to the variable.
B. Loosely typed, values of any type can be assigned to any variable.
A. none of these
B. the dot notation in JavaScript.
C. the redirect notation in JavaScript.
A. lastIndex
B. source
C. All of these
D. ignoreCase
A. Only returns true if the argument is not a number
B. Converts a non-numeric value to a number.
C. Throws an error if a conditional statement is false.
A. used inside of an `if` statement. To specify the code that should execute if the `if` condition is no longer true.
B. used together with the `if` statement to specify the code that should execute when the `if` condition is false.
C. Does not exist, in JavaScript `or` and `then` are used to specify code to execute for the "false" case of the `if` statement.
A. Represent the name of different variables
B. Represent the name of the same constant
C. Represent the name of the same variable
D. Represent the name of different constants
A. Manipulating Web Page Behaviors
B. Styling web pages
C. A website cannot be created without JavaScript
D. None of the above.
E. Content definition within web pages