JavaScript Built-in Objects Quiz
24 Questions
1 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What method is used to set date values for a date object?

  • Object Method
  • Date Method
  • Get Method
  • Date Set Method (correct)

Which of the following methods is NOT a part of the String Object?

  • charAt()
  • split()
  • substring()
  • Math.sqrt() (correct)

Which method would you use to retrieve the character at a specific position in a string?

  • charAt() (correct)
  • substring()
  • indexOf()
  • toString()

What is the primary purpose of the Browser Object Model (BOM)?

<p>To interact with browser-specific functionalities (B)</p> Signup and view all the answers

In JavaScript, what are the two main components that objects serve as containers for?

<p>Properties and methods (C)</p> Signup and view all the answers

Which object would you use in JavaScript to perform mathematical tasks?

<p>Math object (C)</p> Signup and view all the answers

What method can you use to close the current window in the browser?

<p>Window.close() (C)</p> Signup and view all the answers

To return the width of the visitor's screen in pixels, which object and property would you use?

<p>Screen.width (A)</p> Signup and view all the answers

Which of the following accurately describes the built-in objects in JavaScript?

<p>They provide functionalities such as mathematical calculations and array manipulation. (C)</p> Signup and view all the answers

What is the purpose of the Document Object Model (DOM)?

<p>It facilitates interaction with browser-specific functionalities and document representation. (A)</p> Signup and view all the answers

Which statement about the Date object is incorrect?

<p>The Date object can format dates but cannot manipulate them. (C)</p> Signup and view all the answers

Which method retrieves the highest value among given numbers?

<p>Math.max(x,y,z,...n) (B)</p> Signup and view all the answers

What syntax would you use to retrieve the base 10 logarithm of a number?

<p>Math.LOG10E (A)</p> Signup and view all the answers

What is the correct syntax to round a number down to the nearest integer?

<p>Math.floor(x) (B)</p> Signup and view all the answers

Which of the following statements about JavaScript Math properties is false?

<p>Math methods can be called without any arguments. (D)</p> Signup and view all the answers

Which method allows you to adjust date objects by setting specific date and time components?

<p>Date.setUTC() (C)</p> Signup and view all the answers

What method should be used to load a new document in the window location object?

<p>window.location.assign() (D)</p> Signup and view all the answers

Which methods can be used to navigate back and forward in the browsing history?

<p>history.back() and history.forward() (C)</p> Signup and view all the answers

Which of the following describes the three window popup boxes correctly?

<p>Alert box, confirm box and prompt box (C)</p> Signup and view all the answers

What is the purpose of a confirm box?

<p>To verify or accept something by clicking 'OK' or 'Cancel' (C)</p> Signup and view all the answers

Which statement is false regarding a prompt box?

<p>It returns true if 'OK' is pressed. (A)</p> Signup and view all the answers

Which of the following methods is not part of the HTML DOM concept?

<p>JS can format existing HTML elements. (C)</p> Signup and view all the answers

What is the correct method to access elements by their class name in a document object?

<p>document.getElementsByClassName(name) (D)</p> Signup and view all the answers

How can you modify the content of an HTML element most easily?

<p>By using the innerHTML property (D)</p> Signup and view all the answers

Flashcards

Built-in Objects

Pre-defined objects in JavaScript that provide ready-made functionalities.

DOM (Document Object Model)

A programming interface that lets JavaScript interact with and manipulate web pages.

Math.min()

Returns the smallest number in a list of numbers.

Math.floor()

Rounds a number down to the nearest whole number.

Signup and view all the flashcards

Date object

Represents dates and times in JavaScript and enables date manipulation.

Signup and view all the flashcards

Math.sqrt()

Calculates the square root of a number.

Signup and view all the flashcards

Math.log10()

Calculates the base-10 logarithm of a number.

Signup and view all the flashcards

Math properties

Constants like Math.PI (pi) or Math.E (Euler's number) .

Signup and view all the flashcards

Date object method for setting date values

Methods used to change the date and time values of a date object.

Signup and view all the flashcards

String object's character extraction method

Retrieves a specific character from a string based on its position.

Signup and view all the flashcards

Methods for string manipulation: extracting and splitting

substring to extract part of a string, split to divide it into parts.

Signup and view all the flashcards

Browser Object Model (BOM)

Collection of objects that allow JavaScript to interact with browser features like windows, navigation and more.

Signup and view all the flashcards

Components of JavaScript objects

Objects in JavaScript are made up of properties (data) and methods (actions).

Signup and view all the flashcards

JavaScript Math object

Built-in object for mathematical operations on numbers.

Signup and view all the flashcards

Components of the Browser Object Model (BOM)

The BOM includes objects like Window, Navigator, Location, History, and Screen.

Signup and view all the flashcards

Closing a window using JavaScript

The window.close() method is used to close the current window.

Signup and view all the flashcards

window.location.assign()

Loads a new document into the browser window.

Signup and view all the flashcards

history.back() / history.forward()

Navigates backward/forward through browser history.

Signup and view all the flashcards

Alert, Confirm, Prompt Boxes

Popup boxes for user interaction (displaying messages, getting input).

Signup and view all the flashcards

Alert Box

Displaying a message to the user, requiring the user to click 'OK'.

Signup and view all the flashcards

Confirm Box

Asking for confirmation (yes/no) from the user.

Signup and view all the flashcards

Prompt Box

Displays a message requesting input from the user.

Signup and view all the flashcards

document.getElementById()

Selects an HTML element by its unique ID.

Signup and view all the flashcards

document.getElementByClassName()

Selects HTML element(s) with the given class name.

Signup and view all the flashcards

Study Notes

Built-in Objects

  • Pre-defined objects providing functionalities
  • Included in the browser environment

Document Object Model (DOM)

  • Enables JavaScript to interact with the browser
  • Collection of objects exposed by the browser
  • Allows JS to interact with the browser window, document, and other browser-specific functionalities
  • Provides an interface to create, change or remove elements within a document.

Mathematical Constants and Methods

  • Math.SQRT1_2: Returns the square root of 1/2
  • Math.LOG10E: Returns the base-10 logarithm of e
  • Math.min(): Returns the lowest value among input parameters
  • Math.max(): Returns the highest value among input parameters
  • Math.abs(): Returns the absolute value of a number
  • Math.random(): Generates a random number

Date Object

  • Represents dates and times in JavaScript
  • Allows creating and manipulating dates
  • Extracts specific components (year, month, day, hour, minute, second)

Window and Screen Object

  • Screen.availWidth: Returns width of user's display minus the interface (like taskbar)
  • Screen.width: Returns the total width of the screen.
  • Window.location.href: Returns the URL of the current page.
  • Window.location.assign(): Loads a specified URL

History Object

  • history.back(): Loads the previous URL.
  • history.forward(): Loads the next URL.
  • Alert Box: Informs the user.
  • Confirm Box: Asks a yes/no question.
  • Prompt Box: Asks for input

HTML Document Object Model (DOM)

  • The HTML DOM allows you to execute code when an event occurs
  • Used to change the styles and content of elements.
  • document.getElementById(): Finds an element by its ID.
  • document.getElementByTagName(): Finds elements by tag name.
  • document.getElementByClassName(): Finds elements by class name.
  • innerHTML: Modifies the content of an element, typically used to display or change content.
  • style.property: Modifies styling of an element.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

JS WK9 PDF

Description

Test your knowledge on the built-in objects in JavaScript, including the Document Object Model (DOM) and mathematical constants. This quiz covers functionalities that enable JavaScript to interact with the browser, manipulate dates, and perform mathematical operations. Enhance your understanding of these essential JavaScript concepts.

More Like This

Use Quizgecko on...
Browser
Browser