JS WK9 PDF
Document Details
Uploaded by BetterThanExpectedLearning9144
Yeungjin University
Tags
Summary
This document contains questions about JavaScript programming concepts and includes definitions and explanations of several JavaScript objects like built-in objects, Document Object Model (DOM), and window objects.
Full Transcript
These are pre- defined objects that provide a plethora of functionalities right out of the box. a. Built-in Objects \# b. Document Object c. Array d. Browser Object 2. They come with a variety of properties and methods that enable you to perform common tasks like manipulating arrays, h...
These are pre- defined objects that provide a plethora of functionalities right out of the box. a. Built-in Objects \# b. Document Object c. Array d. Browser Object 2. They come with a variety of properties and methods that enable you to perform common tasks like manipulating arrays, handling dates & times, performing mathematical calculations & much more. a. Browser Object b. Document Object c. Array d. Built-in Object \# 3. Which of the statements below describes DOM? a. It allows JavaScript to "talk to" the browser. b. It includes objects such as Window, Navigator, Location, History and Screen. c. It is a collection of objects exposed by the browser that allows JS to interact with the browser window, document and other browser- specific functionalities. d. A programming interface that allows us to create, change or remove elements from the document. \# 4. Which of the following is the correct syntax use to "returns the square root of ½"? a. Math.E b. Math.PI c. Math.SQRT2 d. Math.SQRT1\_2 \# 5. This syntax is used to "return base 10 logarithm of E". a. Math.LN2 b. Math.LN10 c. Math.LOG2E d. Math.LOG10E \# 6. Which of the following statements is false? a. The syntax for any Math property is Math.property b. The syntax for any Math methods is Math.method (number) c. JS provide 8 mathematical constants that can be accessed as Math properties d. There are 8 common methods to round a number to an integer. \# 7. What syntax do you usually use to return the number with the lowest value? a. Math.min(x,y,z,...n) \# b. Math.max((x,y,z,...n) c. Math.abs(x) d. Math.random() 8. What syntax are you going to use if you want to return x rounded down to its nearest integer? a. Math.round(x) b. Math.ceil(x) c. Math.floor(x) \# d. Math.abs(x) 9. Which of the following statements is false? a. The Date object represents dates and times in JS. b. The Date object allows you to create and manipulate dates. c. The Date object extracts specific components such as year, month, day, hour, minute and second. d. The Date object can format dates but is unable to perform operations like getting current date and time. \# 10. This method allows you to get and set the year, month, day, hour, minute, second and millisecond of date objects using either local time or UTC (universal/GMT) time. a. Date Method \# b. Object Method c. Get Method d. Math Method 11. This method lets you set date values ( years, days, hours, minutes, seconds, milliseconds) for a date object. a. Date Method b. Date Set Method \# c. Get Method d. Object Method 12. This object represents a sequence of characters and provides various methods for manipulating and working with strings. a. charAt() b. split () c. substring() d. String Object \# 13. What method is use to get the character at a specific position in string object? a. charAt() \# b. substring() c. UpperCase() d. LowerCase() 14. In string object, what methods respectively are being used to extract a portion of a string and split a string into an array of substring? a. UpperCase() and LowerCase() b. Substring() and split() \# c. charAt() and split() d. substring() and charAt() 15. This are collection of objects exposed by the browser that allow JS to interact with the browser window, document and other browser- specific functionalities. a. Objects in JS b. Document Object Model c. Browser Object Model \# d. Built- in object 16. Objects in JS are containers for \_\_\_\_\_\_\_\_\_\_\_\_\_and \_\_\_\_\_\_\_\_\_\_ a. DOM and BOM b. Built - object and pre-defined object c. Properties and methods \# d. Programming interface and browser -specific properties 17. This standard built in objects allows you to perform mathematical tasks on numbers. a. String object b. Pre- defined object c. JavaScript Math object \# d. Document Object 18. What objects are included in BOM ? a. Window, Navigator, Location, History and Screen \# b. Browser, document, function , history and variables c. Window, browser, document, history and variables d. Browser, navigation, location , history and screen 19. Under window object which method is describe by this statement "close the current window"? a. Window.open() b. Window.close() \# c. Window.moveTo() d. Window.resize() 20. Under window screen object, what are you going to use if you want to return the width of the visitor's screen in pixel minus interface features like the windows taskbar? a. Screen.width b. Screen.height c. Screen.availWidth \# d. Screen.availHeight 21. In window screen object, what are you going to use if you want to return the width of the visitor's screen in pixels? a. Screen.width \# b. Screen.height c. Screen.availWidth d. Screen.availHeight 22. In window location object, what are you going to use if you want to return the href(URL) of the current page? a. Window.location.href \# b. Window.location.hostname c. window.location.pathname d. window.location.protocol 23. If you want to load a new document under window location object which is the right syntax? a. window.location.hostname b. window.location.pathname c. window.location.protocol d. window.location.assign() \# 24. If you want to load the previous URL and the next URL in the history list which of the following can be used under window history object? a. history.back() and history.forward() \# b. history.previous() and history.next() c. history.before() and history.after() d. history.home() and history.end() 25. What are the three window Popup boxes? a. Cancel box, confirm box and agree box b. Alert box, confirm box and prompt box \# c. Agree box, disagree box and cancel box d. Notification box, comment box and prompt box 26. This window popup box appears if you want to make sure information comes through the user and the user needs to click it "ok" to proceed. a. Alert Box \# b. Confirm Box c. Prompt Box d. Agree box 27. This window popup box is used to verify or accept something by clicking "ok" or "cancel" to proceed. a. Alert Box b. Confirm Box \# c. Prompt Box d. Agree Box 28. Which of the following statements is untrue about prompt box? a. Often used if you want the user to input a value before entering a page. b. When the prompt box pops up, the user will have to click "OK" or "Cancel" to proceed after entering an input value. c. If the user clicks "OK" the box returns the input value and if "Cancel" the box returns null. d. If the user clicks \"OK" the box returns true and if "Cancel\" the box returns false. \# 29. Which of the following statements is not part of concept of HTML DOM? a. JS can change all the HTML elements, attributes and CSS styles in the page. b. JS can remove existing HTML elements and attributes. c. JS can add new HTML elements and attributes d. JS can create new HTML events and react to some existing HTML events on the page. \# 30. Which is the best example of how you can use the document object to access and manipulate HTML by finding elements by class name? a. document.getElementById(id) b. document.getElementByTagName(name) c. document.getElementByClassName(name) \# d. document.getElementByClassName(class) 31. What is the easiest way to modify the content of an HTML element? a. By using HTML DOM b. By using HTML elements c. By using innerHTML property \# d. By using modifyHTML property 32. What syntax can be used to change the content of an HTML element? a. document.getElementById(id).innerHTML = new HTML \# b. document.getElementById(id).style.property = new style c. document.getElementById("demo").innetHTML = "Hello World!"; d. document.getElementById('p2').style.color = "blue"; 33. What syntax can be used to change the style of an HTML element? a. document.getElementById(id).innerHTML = new HTML b. document.getElementById(id).style.property = new style \# c. document.getElementById("demo").innerHTML = "Hello World!"; d. document.getElementById('p2').style.color = "blue"; 34. The HTML DOM allows you to execute code when an event occurs, and these are generated by the browser when "things happen" to HTML elements. Which is not part of events? a. An element is clicked on b. The page has loaded c. Input fields are changed d. The page is locked \# 35. Which of the following syntax will give us an example of changing the style of the HTML element with id= "id", when the user clicks a button? a. \My Heading 1\ \ Click Me! \ \#\#\#\#\# b. \ Hello World!\ \ document.getElementById("p2").style.color = "blue"; \ c. \ \ \ document.getElementById(("demo").innerHTML = "Hello World!"; \ d. \My Heading 1\ \ Click Me! \