Advanced JavaScript: Question Bank
- Categories JavaScript, Advanced JavaScript
This post contains the latest questions on JavaScript in the form of true/false statements, MCQs and fill in the blanks. Try solving the question bank to help in your revision!
Fill in the following blanks:
- There are a variety of scripting languages used to develop _____ websites.
Ans. dynamic
- A _____ is a set of instructions used to produce various kinds of outputs.
Ans. Program
- JavaScript supports _____ programming facility.
Ans. event based
- ____ script resides on web server.
Ans. Server side
- _____ script resides on client computer and can run on the client page.
Ans. Client side
- ______ is a JavaScript based framework for building interactive user interface.
Ans. Vue JS
- _____ is a JavaScript based open source front-end web framework developed for single page application.
Ans. Angular JS
- ____ consists of JS libraries for building UI for single page application and mobile apps.
Ans. React
- In a switch case statement, the value for the case must be of a similar ____ as the variable in switch.
Ans. data type
- _____ property of window sets or returns the fact in the status bar of a window.
Ans. Status
- for-loop has a combination of _____, _____ and _____ in single statement.
Ans. initialization, condition, iteration
- A JavaScript object is an entity having ____ and ____.
Ans. state, behavior
- _____ method of window object display the alert box containing message with OK button.
Ans. alert ()
- An object can group data together with _____ needed to manipulate it.
Ans. functions
- JavaScript supports 2 types of objects; _____ and ____objects.
Ans. built-in, user defined
- Math, String, Array, Date are examples of _____objects.
Ans. built in
- When an HTML document is loaded into a ____, it becomes a document object.
Ans. web browser
- _____ defines logical structure of document.
Ans. Document object
- _____ method of window object calls a function or evaluates an expression after a specified number of milliseconds.
Ans, setTimeout ()
- The ______of DOM was founded by W3C(World Wide Web Consortium).
Ans. standardization
- _____ DOM property is used to set the title of the document.
Ans. Title
- DOM method ____ works same as write(), but adds a newline character after each statement.
Ans. writeln()
- _____ method of number object converts the given string into an integer number.
Ans. parseFloat ()
- _____ method returns cube root of a number.
Ans. cbrt()
- DOM’s ____method is the easiest method for accessing form elements.
Ans. getElementById()
- The ____ property is useful for getting html element and changing its content.
Ans. innerHTML
- _____ object is the peak of the object Hierarchy.
Ans. Window
- _____ Window Object property returns the location object for the window.
Ans. Location
- Window Object method ____ is used to print the content of current window.
Ans. print()
- JavaScript events are actions done by the user or an application that occurs on_____.
Ans. the webpage
- ____ Window Object property returns a boolean value to indicate whether a window is closed or not.
Ans. Closed
- ______ event occurs when user selects some text of an element.
Ans. onselect
- ______ event handler occurs when page/image has been loaded.
Ans. onload
- JavaScript built-in objects provide different ____and ____ that are useful while creating live web pages.
Ans. properties, methods
- ____ is used to store zero or more characters of text within single or double quotes.
Ans. String
- String object is used to ____ and___ text.
Ans. store, manipulate
- String object property _____ is used to return the number of characters in a string.
Ans. length
- String object Method charAt() is used to return the character at a ____ .
Ans. specified position
- ______ String object method is used to remove whitespace from both sides of a string.
Ans. trim()
- The built-in math object includes mathematical ____ and ____.
Ans. constants, functions
- Math method____ returns the base to the exponent power.
Ans. pow(x, y)
- Date method _____ is used to return the day of the week.
Ans. getDay()
- Array property index is used to represent the ____ index of the match in the string.
Ans. zero-based
- Array property _____ reflects number of elements in array.
Ans. length
- _____ array method is used to join two or more arrays.
Ans. concat()
- ____ array method is used to copy array elements within the array.
Ans. copyWithin()
- Array method find() is used to return the value of the ____ in an array that satisfies a test in testing.
Ans. first element
- The index of the first element of an array is ____.
Ans. zero
- Date method getMonth() is used to return ____.
Ans. month
- Which date method is used to set the hours of a date object?
Ans. setHours()
- Date method setMinutes() is used to set the ___of a date object.
Ans. minutes
- Date method ____ is used to set the seconds of a date object.
Ans. setSeconds()
- Number object MIN_VALUE() property returns the largest ___value.
Ans. minimum
- _____ Number property is used to return the largest maximum value.
Ans. MAX_VALUE
- Number property ___ is used to represent ‘Not A Number’ value.
Ans. NaN
- _____ number method is used to convert the given string into a integer number.
Ans. parseInt()
- _____is an object that can store a collection of items.
Ans. Array
- _____ array method is used to reverse the order of the elements in an array.
Ans. reverse()
- _____ array method is used to sort the elements of an array.
Ans. sort()
State whether the following statements are true or false:
- JavaScript is an interpreted scripting language.
Ans. True
- JavaScript was initially created to “make webpages alive”.
Ans. True
- JavaScript is a light weight scripting language because it supports all features of object oriented programming languages.
Ans. False
- Users don’t need any special software to run JavaScript programs
Ans. True
- JavaScript is not a case sensitive language.
Ans. False
- Most of the JavaScript “Control Statements” are same as control statements in other programming languages.
Ans. True
- JavaScript is a platform dependent scripting language
Ans. False
- JavaScript is known as a universal client side scripting language.
Ans. True
- JavaScript has the ability to create new functions within scripts.
Ans. False
- To execute the Server side script, it must be activated by server, and then it is executed on web server.
Ans. False
- JavaScript has a built-in multi-way decision statement known as switch.
Ans. True
- The default statement for switch case is mandatory.
Ans. False
- In switch cases, there should not be duplicity between the cases.
Ans. True
- Iteration refers to the execution of a statement or a group of statements of code for a fixed number of times or till the condition is satisfied.
Ans. True
- The condition of a looping statement should not be Boolean condition.
Ans. False
- Location property of window object returns a Boolean value indicating wheteher the window has been closed or not.
Ans. False
- In for loop, the control comes out from the loop when condition becomes false.
Ans. True
- Initialization executes only once in the for loop.
Ans. True
- The statements in the for loop statement block will execute till the condition is false.
Ans. False
- While loop executes statements as long as the condition is true.
Ans. True
- The statement within the while loop may only have single line statement.
Ans. False
- If condition is always true then the loop would be executed infinitely, so after some execution the condition becomes false.
Ans. True
- Almost everything in JavaScript is an object.
Ans. True
- Properties and methods of objects are accessed with ‘.’ operator.
Ans. True
- JavaScript gives facility to create user defined objects as per user requirements.
Ans. True
- trim() adds white spaces from both sides of a string.
Ans. False
- ceil() method returns the next integer greater than or equal to a given number.
Ans. True
- A break statement is used to make an early exit from a loop.
Ans. True
- World Wide Web Consortium works for standardization of web technologies.
Ans. True
- DOM property “URL” returns full URL of the HTML document.
Ans. True
- DOM property “img” returns Error! Filename not specified.
Ans. True
- DOM method write() is used to write HTML expressions or JavaScript code to A document.
Ans. True.
- DOM method getElementById() uses id property to find an element.
Ans. True
- pow() method returns the base to the exponent power.
Ans. True
- The innerHTML property can be changed by any HTML element, includingand.
Ans. True
- Window object is the parent object of all other objects.
Ans. True
- Window Object property “document” is used to return the document object for the window.
Ans. True
- confirm() Method is used to open new window in Window Object
Ans. False
- Window Object Method close() is used to close the current window.
Ans. True
- Window Object method blur() is used to add focus to the current window.
Ans. False
- JavaScript Event Handler “onblur” occurs when the user leaves the field or losses focus of an element.
Ans. True
- JavaScript Event Handler “onfocus” occurs when an element losses focus.
Ans. False
- “onreset” Event Handler occurs when user clicks the cancel button.
Ans. False
- JavaScript built-in objects operate independently.
Ans. True
- Users always need to create the Math object before using it.
Ans. False
- cbrt(x) Math method returns the cube root of a number.
Ans. True
- Math method random(x) gives random number between 0 and 10.
Ans. False
- Math method sqrt(x) gives the square root of a number.
Ans. True
- The Date object is used to create date and time values.
Ans. True
- Date Method getFullYear() is used to return the year in four digits.
Ans. True
- Date Method getHours() is used to return the hour from 0-12.
Ans. False
- Arrays are useful when we need to store large amounts of data of the same type.
Ans. True
- Arrays are used to store single values in single variables.
Ans. False
- You set the items in an array by referring to its item number.
Ans. False
- Array method forEach() is used to call a function for some array element.
Ans. False
- Date getSeconds() Method is used to return the seconds from 0-24.
Ans. False
- Date Method getTime() is used to return the number of milliseconds since midnight Jan 1, 1970 00.00.00.
Ans. True
- Date Method setFullYear() is used to set the full year if a date object.
Ans. True
- Date Method setMonth() is used to set the year of a date object.
Ans. False
- Number object helps us to work with numbers.
Ans. True
- JavaScript does not provide properties and methods for primitive values.
Ans. False
- Number method isInteger() determines whether the given value is an integer.
Ans. True
- Array method push() adds new elements to the end of an array.
Ans. True
Multiple choice questions:
- An interpreted language is a type of programming language that executes its instructions ____.
- Indirectly
- Directly
- Partially
- None of above
Ans. 2
- The programs in this language are called____.
- Page
- Webpage
- Scripts
- Block
Ans. 3
- JavaScript helps the browser to perform_____ validation.
- Output
- Input
- Both of above
- None of above
Ans. 2
- JavaScript provides the ability to create new functions within____.
- Scripts
- Function
- Class
- None of above
Ans. 1
- We can declare a function in JavaScript using ____ keyword.
- New
- Function
- Default
- Do
Ans. 2
- Client side scripts are placed inside ____document.
- Word
- HTML
- XML
- Text
Ans. 2
- JavaScript has a built–in multiway decision statement known as___.
- If else
- Do while
- Switch
- for
Ans. 3
- _____is assigning initial value to the variable.
- Condition
- Initialization
- Iteration
- None of above
Ans. 2
- In the ‘for loop’, when condition becomes ___control is transferred out of the loop.
- True
- False
- End
- Terminate
Ans. 2
- If the statement within while loop is a single line then the ____ parenthesis is optional.
- Square
- Curly
- Round
- None of above
Ans. 2
- Loop will be executed repeatedly till the ____is true.
- Condition
- Initialization
- Iteration
- None of above
Ans. 1
- ____statement is used to jump out of loop.
- End
- Out
- Break
- Remove
Ans. 3
- What happens if the break statement is encountered inside the loop?
- Control goes to next statement
- Control goes to next statement after the loop
- Program will stop unexpectedly
- Skip the current statement and continue with next statement
Ans. 2
- _____ statement is used to skip statement block and take the control at the beginning for next iteration.
- Break
- Continue
- Jump
- None of above
Ans. 2
- JavaScript is a ____based scripting language.
- Object
- Data
- Variable
- Datatype
Ans. 1
- The ‘new’ keyword is used to create new _____ in JavaScript.
- Object
- Function
- Variable
- None of above
Ans. 1
- DOM property “body” returns___ elements.
- URL
- Title
Ans. 4
- Window object represents ____window in a browser.
- Name of
- Closed
- Open
- Status
Ans. 3
- An object of window is created automatically by the___.
- User
- Server
- Browser
- None of above
Ans. 3
- Which Window Object property is used to set the name of a window?
- Document
- Name
- Status
- Location
Ans. 2
- Status Window Object property is used to set the text in the ____of a window.
- Tool bar
- Status bar
- Title bar
- Menu bar
Ans. 2
- The Window Object Method____ displays the alert box containing message with OK button.
- prompt()
- ALERT()
- confirm()
- blur()
Ans. 2
- Which Window Object Method displays the confirm dialog box?
- ALERT()
- confirm()
- blur()
- focus()
Ans. 2
- Which Window Object method is used to set focus to the current window?
- prompt()
- confirm()
- blur()
- focus()
Ans. 4
- “onsubmit” event handler is used when user clicks ____button.
- Cancel
- Submit
- Ok
- None of above
Ans. 2
- abs(X) math method is used to return _____ of number.
- Cube
- Square
- Absolute
- None of above.
Ans. 3
- Date object can be created using ____ keyword.
- Now
- New
- Create
- None of above
Ans. 2
- Date method getDate() is used to return the day of the ____.
- Year
- Month
- Week
- Both of above
Ans. 2
- Which date method returns the minutes?
- getSeconds()
- getTime()
- setMinutes()
- getMinutes()
Ans. 4
- Date setDate() Method is used to set the day of the ___ of a date object.
- Month
- Year
- Weak
- None of above
Ans. 1
- JavaScript arrays are used to store multiple values in ___variable.
- Double
- Single
- Both of above
- None of above
Ans. 2
- ____ is a special variable which can hold more than one value at a time.
- Array
- List
- Number
- String
Ans. 1
- The index of the first element of an array is____.
- One (1)
- Zero(0)
- Minus one (-1)
- Any number.
Ans. 2
- _______ scripts are used for validation purposes.
- Website
- Server side
- Client side
- Web browser
Ans. 3
- All tangible things are known as ____.
- Methods
- Objects
- Functions
- Variables
Ans. 2
- _____ array method is used to remove the last element of an array, and return that element.
- Push()
- Pop()
- Sort()
- Reverse()
Ans. 2