Week 9
39 Questions
2 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 is the primary function of built-in objects in JavaScript?

  • To define user interfaces
  • To manage database connections
  • To provide functionalities out of the box (correct)
  • To enhance graphical processing
  • Which of the following accurately describes the Document Object Model (DOM)?

  • It is the structure of JavaScript code.
  • It solely enables CSS styling.
  • It allows JavaScript to interact with browser content. (correct)
  • It represents the programming interface for web servers.
  • Which syntax is correct to return the square root of $\frac{1}{2}$?

  • Math.SQRT2
  • Math.PI
  • Math.E
  • Math.SQRT1_2 (correct)
  • Which method is used to find the highest value among given numbers?

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

    What statement about the Date object is false?

    <p>It can format dates but cannot get the current date.</p> Signup and view all the answers

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

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

    Which Math property is not commonly accessed using the Math object?

    <p>Math.COS</p> Signup and view all the answers

    Which method would you use to obtain the logarithm base 10 of $e$?

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

    What is the output of Math.random()?

    <p>Returns a random number between 0 and 1</p> Signup and view all the answers

    Which of the following describes a property of JavaScript Math methods?

    <p>Math methods provide mathematical calculations</p> Signup and view all the answers

    What is the correct method to load a new document using the window location object?

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

    Which methods can be called to navigate backwards and forwards in the history list?

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

    Which of the following are the correct types of window popup boxes?

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

    What type of popup box requires the user to click 'OK' to proceed?

    <p>Alert Box</p> Signup and view all the answers

    What is the key characteristic of a Confirm Box?

    <p>It allows a decision by clicking 'OK' or 'Cancel'.</p> Signup and view all the answers

    Which statement about the prompt box is untrue?

    <p>If 'OK' is clicked, the box returns true.</p> Signup and view all the answers

    Which statement does not pertain to the concept of HTML DOM?

    <p>JS can create new HTML attributes.</p> Signup and view all the answers

    Which method is best for accessing elements by class name in the document object?

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

    What is the easiest way to modify the content of an HTML element?

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

    Which method allows you to set date values for a date object?

    <p>Date Set Method</p> Signup and view all the answers

    What method is used to retrieve the character at a specified index in a string?

    <p>charAt()</p> Signup and view all the answers

    Which methods are used to extract a portion of a string and split a string into an array?

    <p>Substring() and split()</p> Signup and view all the answers

    Which model allows JavaScript to interact with browser-specific functionalities?

    <p>Browser Object Model</p> Signup and view all the answers

    Objects in JavaScript act as containers for which two components?

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

    Which built-in object is designed for performing mathematical operations?

    <p>JavaScript Math object</p> Signup and view all the answers

    What objects are part of the Browser Object Model (BOM)?

    <p>Window, Navigator, Location, History and Screen</p> Signup and view all the answers

    Which method under the window object is used to close the current window?

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

    To return the width of the user's screen in pixels minus interface features, which method should be used?

    <p>Screen.availWidth</p> Signup and view all the answers

    To obtain the URL of the current page using the window location object, which property should be accessed?

    <p>Window.location.href</p> Signup and view all the answers

    What syntax correctly changes the content of an HTML element?

    <p>document.getElementById('demo').innerHTML = 'Hello World!';</p> Signup and view all the answers

    Which option demonstrates the correct way to modify an element's style?

    <p>document.getElementById(id).style.property = new style</p> Signup and view all the answers

    Which of the following is NOT considered an event in JavaScript?

    <p>The page is locked</p> Signup and view all the answers

    What is incorrect about the following syntax for changing element content: document.getElementById('demo').innetHTML = 'Hello World!'; ?

    <p>innetHTML is a typo; it should be innerHTML</p> Signup and view all the answers

    Which code will successfully change the text color to blue upon a button click?

    <p><button onclick='document.getElementById("p2").style.color = "blue";'>Click Me!</button></p> Signup and view all the answers

    Which activity does NOT generate an event in the HTML DOM?

    <p>The browser is minimized</p> Signup and view all the answers

    Identifying a correct action, what does document.getElementById('p2').style.color = 'blue'; accomplish?

    <p>It sets the text color of element p2 to blue.</p> Signup and view all the answers

    How can you ensure code runs after the webpage finishes loading?

    <p>Using the window.onload function</p> Signup and view all the answers

    In JavaScript, what does the syntax document.getElementById(id).style.property = new style aim to achieve?

    <p>Modifying the visual style property of an element</p> Signup and view all the answers

    What JavaScript code snippet will correctly change the text displayed in an element with id 'demo'?

    <p>document.getElementById('demo').innerHTML = 'Hello World!';</p> Signup and view all the answers

    Study Notes

    Built-in Objects

    • Pre-defined objects providing various functionalities
    • Included right away

    Document Object Model (DOM)

    • JavaScript interacts with the browser
    • Includes objects like Window, Navigator, Location, History, Screen
    • Allows JavaScript to interact with the browser window, document, and other browser-specific functionalities
    • Enables creation, modification, and removal of document elements

    Mathematical Constants and Methods

    • Math.SQRT1_2: Returns the square root of 1/2
    • Math.LOG10E: Returns the base-10 logarithm of Euler's number (e)
    • Math.min(): Returns the lowest value among the provided numbers
    • Math.max(): Returns the highest value among the provided numbers
    • Math.abs(): Returns the absolute value of a number
    • Math.random(): Returns a random number between 0 (inclusive) and 1 (exclusive)
    • Math.round(): Rounds a number to the nearest integer
    • Math.ceil(): Rounds a number up to the nearest integer
    • Math.floor(): Rounds a number down to the nearest integer

    Date Object

    • Represents dates and times
    • Includes year, month, day, hour, minute, and second
    • Retrieves the current date and time
    • Creates date/time values
    • Allows manipulation of date-related information

    String Object

    • Sequence of characters
    • Provides methods for manipulating and working with strings

    String Object Methods

    • charAt(): Retrieves the character at a specified index
    • substring(): Extracts a portion of a string
    • split(): Divides a string into an array of substrings

    Window Object

    • Interaction with the browser window
    • window.location.href: Retrieves the URL (Uniform Resource Locator) of the current web page
    • window.location.assign(): Loads a new document into the browser by navigating to a new URL.
    • window.close(): Closes the current window
    • window.open(): Opens a new browser window
    • screen.width: Retrieves the width of the browser's screen in pixels
    • screen.height: Retrieves the height of the browser's screen in pixels
    • screen.availWidth: Retrieves the width of the screen available for the application, minus the operating system's interface elements.
    • screen.availHeight: Retrieves the height of the screen available for the application, minus the operating system's interface elements.

    Window Popup boxes

    • Alert box: Displays a message to the user, prompting a single "OK" button
    • Confirm box: Displays a message with a "OK" button and a "Cancel" button
    • Prompt box: Displays a message and input field, allowing the user to enter a value. Informs the user to make sure about needed actions

    HTML DOM

    • Provides a way of accessing and modifying elements in HTML (HyperText Markup Language)
    • document.getElementById(): retrieves the element with the corresponding ID.
    • document.getElementsByTagName(): retrieves all elements with the corresponding tag.
    • document.getElementsByClassName(): retrieves all elements of the specified class.
    • innerHTML: Modifies the content within an HTML element
    • style: Modifies the CSS style attributes

    HTML Events

    • Execution of code when an event occurs on an HTML element
    • Events are automatically triggered by the browser (e.g. page load, clicks, input changes)

    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

    Explore the essential built-in objects and mathematical constants in JavaScript. This quiz covers the Document Object Model (DOM) and various Math methods that help in numerical computations and browser interaction. Test your knowledge on how JavaScript interacts with the browser and performs mathematical operations.

    More Like This

    Use Quizgecko on...
    Browser
    Browser