















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Math. ○ Math in JavaScript uses the follow operators. – Addition: +. – Subtraction: - ... Functions allow us to write code that reacts to.
Typology: Summaries
1 / 55
This page cannot be seen from the preview
Don't miss anything!
















































CS 0134
● JavaScript is a programming language that was designed to run in your web browser.
● The script element is used to define client-side scripts for a web page ● In HTML5, by default, the browser assumes any scripts defined by the script element to be written in JavaScript ● You can define JavaScript with the script element in two ways
● While not required, it is beneficial to place the script element as the last child before the body’s closing tag as this speeds up the loading of your web pages ● Like CSS, it is advisable to keep your JavaScript in a separate file
● script.js console.log("Hello World!"); ● **In HTML file just before closing body tag **
● Modern desktop web browsers come with a console ● The console lets you see messages, warnings and errors related to your web page ● You open the console with Ctrl+Shift+K (Cmd+Option+K) in Firefox
● Variables are used to store data ● To define a variable you use the keyword let followed by a variable name ● Naming variables
● You can assign a value to a variable using the form "variable = value" ● You can do this assignment both when you define the variable as well as further on in the script ● JavaScript variables have scope, more on that later ● JavaScript is a language that uses dynamic typing. What this means is that you can assign any value to a variable and change the type of the value throughout the script
● JavaScript has the following types of data that we can work with
● Numbers are numerical values between -( 53
- 1) and ( 53 - 1) (also known as -9,007,199,254,740,991 and 9,007,199,254,740,991) ● Numbers can be written as integers, decimals and scientific notation ● In addition to explicit numbers, a number can be represented with -Infinity, +Infinity and NaN (not a number)
● Booleans are the values true and false ● Examples
● null represents no value ● Undefined happens when a variable has been declared but no value has been defined ● Examples
● You can access a value in an array by using the arrays variable name followed by the values index in brackets ● An array index is a numerical value that points to where the value exists in the array; The index for the first value in an array is 0 and increments for every value in the array ● Example
● Math in JavaScript uses the follow operators