Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,150,331 members, 7,808,106 topics. Date: Thursday, 25 April 2024 at 07:19 AM |
Nairaland Forum / Science/Technology / Programming / The Beauty & Power Of JavaScript: "Hello World" Code As A Case Study (1295 Views)
Who Has Idea Of Use Of Javascript In Selenium Webdriver&java For Software Testin / How To Say "Hello World" In Different Programming Languages / Simple, Rich & Fast Approach To Learning Javascript. Whatsapp Group Inclusive (2) (3) (4)
(1) (Reply)
The Beauty & Power Of JavaScript: "Hello World" Code As A Case Study by Olumyco(m): 9:38pm On Jan 30, 2016 |
JavaScript is beautiful and powerful. It's fun coding with it. Can you imagine that the popular example of print/output "Hello World" code can be done in JavaScript in different ways and styles. Check it out! // JAVASCRIPT WITH CONSOLE console.log("Hello World" console.info("Hello World" // JAVASCRIPT WITH DOM - DOCUMENT OBJECT MODEL (HTML DOCUMENT) ................................................. <!DOCTYPE html> <html> ...... // add others tags <body> <p name="p" id="p" class="p"></p> </body> </html> ................................................. document.write("Hello World" document.body.innerHTML = "Hello World"; document.getElementsByTagName("p"[0].innerHTML = "Hello World"; document.getElementsByName("p"[0].innerHTML = "Hello World"; document.getElementById("p".innerHTML = "Hello World"; document.querySelector("#p".innerHTML = "Hello World"; document.querySelector(".p".innerHTML = "Hello World"; // JAVASCRIPT WITH BOM - BROWSER OBJECT MODEL (BROWSER WINDOW) window.alert("Hello World" // Or: can be written with or without the window object. alert.("Hello World" //JAVASCRIPT ITSELF function output(anything) { return anything; } output("Hello World" function print() { return "Hello World"; } print(); Wao! 12 different ways. Minus the "OR alert" optional code...... JavaScript Rocks!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2 Likes |
Re: The Beauty & Power Of JavaScript: "Hello World" Code As A Case Study by Everest25(m): 6:25pm On Jan 31, 2016 |
please can some one explain these html tags for me coz am a beginner <class>, <div>,<span>...thanks |
(1) (Reply)
Which Is The Best Bulk SMS Service Provider? / How To Fix Dot Net Framework Installation On Windows 7 Ultimate / Download 18 Python Programming Books For Beginners And Veterans
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 10 |