<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <!-- Playing with client-side JavaScript, and demoing some of its functional programming features by: Sharon Tuttle last modified: 2026-04-28 you can run this using the URL: https://nrs-projects.humboldt.edu/~st10/s26cs328/328lect14-1/js-play.html --> <head> <title> JS playing </title> <meta charset="utf-8" /> <link href="https://nrs-projects.humboldt.edu/~st10/styles/normalize.css" type="text/css" rel="stylesheet" /> <!-- use a script element to add JavaScript in an HTML document's head element --> <script type="text/javascript"> // ADDED after class: when added at the VERY TOP of a // script element or external JavaScript (.js file) // or JavaScript function body, // enforces JavaScript strict mode, a restricted variant // of JavaScript that does not allow certain "sloppy" // uses of JavaScript "use strict"; // setting variable looky to an anonymous function let looky = function() { alert("Called by a function with no name"); }; // now calling this function using looky looky(); // you can have named functions, also function named() { alert("called by a NAMED function"); } named(); // you can assign a variable a value that is a named function let alsoAFunct = named; alsoAFunct(); // you can have a function with a function as its // parameter function silly(funct_param) { alert("BEGINNING of function silly"); funct_param(); alert("END of body of silly!"); } silly(looky); silly(named); silly(alsoAFunct); // NOTICE: // when a variable has a function as its value, // its name is an expression whose value // is that function! // // looky // is an expression of type function // // BUT when you put () after that variable's name, // the expression's value will be the result // of CALLING its function value with no arguments!! // // looky() // is an expression whose value would // // be the result of calling the function // // that is looky's value // UNCOMMENT the following to see the error if you // call function silly with an argument NOT of type // function! // silly(looky()); alert("the HEAD element JavaScript popup nightmare is now over!"); </script> </head> <body> <h1> JavaScript Play! </h1> <p> <strong>WARNING</strong>: this page does NOTHING if JavaScript is disabled! </p> <footer> <hr /> <p> Validate by pasting .xhtml copy's URL into<br /> <a href="https://validator.w3.org/nu"> https://validator.w3.org/nu </a> or <a href="https://html5.validator.nu/"> https://html5.validator.nu/ </a> </p> </footer> </body> </html>