










Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!











JavaScript ๏ (^) Introduction ๏ (^) JavaScript is a scripting or programming language that allows you to implement complex things on web pages โ every time a web page does more than just sit there and display static information for you to look at โ displaying timely content updates, interactive maps, animated 2D/3D graphics, scrolling video jukeboxes, etc.
Basic Functionaliti es ๏ (^) After Clicking Turn on button ๏ (^) The attribute โsrcโ is changed.
Basic Functionaliti es ๏ (^) JavaScript Can Change HTML Styles (CSS) ๏ (^) E.g. document.getElementById("demo").style.fontSize = " 35px"; ๏ (^) JavaScript Can Hide / show HTML Elements ๏ (^) E.g. document.getElementById("demo").style.display = "b lock/none";
Functions and Events ๏ (^) A JavaScript function is a block of JavaScript code, that can be executed when "called" for. ๏ (^) For example, a function can be called when an event occurs, like when the user clicks a button. ๏ (^) JavaScript in or ๏ (^) You can place any number of scripts in an HTML document. ๏ (^) Scripts can be placed in the , or in the section of an HTML page, or in both. ๏ (^) E.g.
๏ (^)
A Paragraph
Try it ๏ (^)Javascript Output ๏ (^) JavaScript Display Possibilities ๏ (^) JavaScript can "display" data in different ways: ๏ (^) Writing into an HTML element, using innerHTML. ๏ (^) Writing into the HTML output using document.write(). ๏ (^) Writing into an alert box, using window.alert(). ๏ (^) Writing into the browser console, using console.log(). ๏ (^) Writing into an HTML element, using innerHTML. ๏ (^)
JS Varibales ๏ (^) The Assignment Operator ๏ (^) x = x + 5 ๏ (^) JavaScript Data Types ๏ (^) JavaScript variables can hold numbers like 100 and text values like "John Doe". ๏ (^) In programming, text values are called text strings. ๏ (^) Example ๏ (^) var pi = 3.14; var person = "John Doe"; var answer = 'Yes I am!';
JS Variables ๏ (^) Declaring (Creating) JavaScript Variables ๏ (^) var carName; ๏ (^) var carName = "Volvo"; ๏ (^)
๏ (^) var person = "John Doe", carName = "Volvo", price = 200;
JS Operators ๏ (^) Adding Strings and Numbers ๏ (^) Example ๏ (^) var x = 5 + 5; var y = "5" + 5; var z = "Hello" + 5; ๏ (^) The result of x , y , and z will be: ๏ (^10) 55 Hello
Functions ๏ (^) JavaScript Function Syntax ๏ (^) A JavaScript function is defined with the function keyword, followed by a name , followed by parentheses (). ๏ (^) Function names can contain letters, digits, underscores, and dollar signs (same rules as variables). ๏ (^) The parentheses may include parameter names separated by commas: ( parameter1, parameter2, ... ) ๏ (^) The code to be executed, by the function, is placed inside curly brackets: {} ๏ (^) function name ( parameter1, parameter2, parameter3 ) { code to be executed }
Functions Used as Variable Values ๏ (^) var x = toCelsius(77); var text = "The temperature is " + x + " Celsius"; ๏ (^) You can use the function directly, as a variable value: ๏ (^) var text = "The temperature is " + toCelsius(77) + " Celsius";
JS Objects ๏ (^)
๏ (^) ๏ (^) Accessing Object Properties ๏ (^) objectName.propertyName