Make Code Dynamic: Change variable values to alter program behavior.\n<\/li>\n<\/ul>\nlet name = \"John\"; \/\/ Storing the value \"John\" in a variable called name\nconsole.log(name); \/\/ Outputs: John\n<\/pre>\n\n\nFunctions:<\/strong>
\n In JavaScript, functions are reusable blocks of code designed to
\n perform a specific task. They allow you to write a piece of logic
\n once and use it multiple times, making your code more efficient and
\n organized.
\n<\/p>\n\nfunction greet(name) {\n return \"Hello, \" + name;\n}\n\nconsole.log(greet(\"Alice\")); \/\/ Output: Hello, Alice\nconsole.log(greet(\"Bob\")); \/\/ Output: Hello, Bob\n<\/pre>\n\n\n\n*Events: *<\/em>
\n Events in JavaScript are actions or occurrences that happen in the browser, often triggered by the user (e.g., clicking a button, typing in an input field, or resizing the window). JavaScript can “l(fā)isten” for these events and perform specific actions in response. This is a key concept for creating interactive and dynamic web pages.
\n<\/p>\n\n\n\n JavaScript Example<\/title>\n<\/head>\n\n \n\n\n\n
Explanation:<\/p>\n\n<\/pre>\n
\n- The getElementById(\"heading\") selects the 'h1' element.<\/li>\n
- .innerText = \"Hello, JavaScript!\"; changes its text.<\/li>\n<\/ul>\n\n
Button Click Example
\nYou can make a button do something when clicked.
\n<\/p>\n\n
\n\n\n Click Example<\/title>\n<\/head>\n\n