Basic And Variables(Javascript ) Questions and Answers

Question 1. A linkage of series of prototype objects is called as :
  1.    prototype stack
  2.    prototype chain
  3.    prototype class
  4.    prototypes
Explanation:-
Answer: Option B. -> prototype chain
Consider an example, Date.prototype inherits properties from Object.prototype, so a Date object created by new Date() inherits properties from both Date.prototype and Object.prototype. This linked series of prototype objects is known as prototype chain.

Question 2. Consider the below given syntax
book[datatype]=assignment_value;
In the above syntax, the datatype within the square brackets must be
  1.    An integer
  2.    A String
  3.    An object
  4.    None of the mentioned
Explanation:-
Answer: Option B. -> A String
When using square bracket notation, the expression inside the square brackets must evaluate to a sting or a value that can be converted to a string.

Question 3. Consider the following code snippet :
var book = {
"main title": "JavaScript",
'sub-title': "The Definitive Guide",
"for": "all audiences",
author: {
firstname: "David",
surname: "Flanagan"
}
};
In the above snippet, firstname and surname are
  1.    properties
  2.    property values
  3.    property names
  4.    objects
Explanation:-
Answer: Option C. -> property names
firstname and surname are the property names. The value of that particular property is itself an object. That is why these property names are unquoted.

Question 4. The object has three object attributes namely
  1.    Class, parameters, object’s extensible flag
  2.    Prototype, class, objects’ parameters
  3.    Prototype, class, object’s extensible flag
  4.    Native object, Classes and Interfacces and Object’s extensible flag
Explanation:-
Answer: Option C. -> Prototype, class, object’s extensible flag
Every object has three associated object attributes :
1. An object’s prototype is a reference to another object from which properties are inherited.
2. An object’s class is a string that caegorizes the type of an object.
3. An object’s extensible flag specifies whether new properties may be added to the object.

Question 5. To determine whether one object is the prototype of (or is part of the prototype chain of) another object, one should use the
  1.    isPrototypeOf() method
  2.    equals() method
  3.    === operator
  4.    none of the mentioned
Explanation:-
Answer: Option A. -> isPrototypeOf() method
To determine whether one object is the prototype of (or is part of the prototype chain of) another object, one should use the isPrototype() method. To find out if p is the prototype of o write p.isPrototypeOf(o).

Question 6. Consider the following snippet code
var string1 = ”123”;
var intvalue = 123;
alert( string1 + intvalue );
The result would be
  1.    123246
  2.    246
  3.    123123
  4.    Exception
Explanation:-
Answer: Option C. -> 123123

Question 7. The property of a primary expression is
  1.    stand-alone expressions
  2.    basic expressions containing all necessary functions
  3.    contains variable references alone
  4.    complex expressions
Explanation:-
Answer: Option A. -> stand-alone expressions
The simplest expressions, known as primary expressions, are those that stand alone — they do not include any simpler expressions. Primary expressions in JavaScript are constant or literal values, certain laguage keywords, and variable references.

Question 8. A function definition expression can be called
  1.    Function prototype
  2.    Function literal
  3.    Function definition
  4.    Function declaration
Explanation:-
Answer: Option B. -> Function literal
A function definition expression is a “function literal” in the same way that an object initializer is an “object literal.” A Function definition expression typically consists of the keyword function followed by a comma-separated list of zero or more identifiers (the parameter names) in parentheses and a block of JavaScript code (the function body) in curly braces.

Question 9. The JavaScript’s syntax calling ( or executing ) a function or method is called
  1.    Primary expression
  2.    Functional expression
  3.    Invocation expression
  4.    Property Access Expression
Explanation:-
Answer: Option C. -> Invocation expression
An invocation expression is JavaScript’s syntax for calling (or executing) a function or method) It starts with a function expression that identifies the function to be called.

Question 10. Consider the following statements
var text = "testing: 1, 2, 3"; // Sample text
var pattern = /d+/g // Matches all instances of one or more digits
In order to check if the pattern matches with the string “text”, the statement is
  1.    text==pattern
  2.    text.equals(pattern)
  3.    text.test(pattern)
  4.    pattern.test(text)
Explanation:-
Answer: Option D. -> pattern.test(text)
The given pattern is applied on the text given in the parenthesis.