Advertisement
DJ_Zoning

document properties

Jul 17th, 2014
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Properties
  2. //Write a JavaScript function displayProperties(value) that displays all the
  3. //properties of the "document" object in alphabetical order. Write a JS
  4. //program docProperties.js that invokes your function with the sample input
  5. //data below and prints the output at the console.
  6.  
  7.  
  8. function displayProperties(value) {
  9.  
  10.     var arr = [];
  11.  
  12.     for (var property in value) {
  13.         arr.push(property);
  14.     }
  15.     arr.sort();
  16.  
  17.     for (var element in arr) {
  18.  
  19.         console.log(arr[element]);
  20.         document.writeln(arr[element]);
  21.     }
  22. }
  23.  
  24.  
  25. displayProperties(document);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement