You are on page 1of 4

Javascript summary

Ilias ahmed

Oracle ocp rhce mscp

Java ocjp

Chapter 1

 An algorithm is a set of step-by-step instructions that complete a specific task.


 Pseudocode is used to write programs without using a specific programming
language.
 JavaScript was created in 1995 and is considered to be the language of the Web.
 JavaScript’s main environment is the browser, but it can also run in other
environments.
 Each version of JavaScript has to be backward compatible with older versions.
 Code should be easy to read and regularly refactored to keep it running
smoothly.
 Remember the DRY principle when coding. Don’t Repeat Yourself!
Chapter 2

 Comments are ignored by the program, but make your program easier to read
and understand.
 Primitive types are the basic building blocks of a program.
 Primitive types in JavaScript include strings, numbers and Booleans.
 Composite data types are structured collections of primitive data types.
 Composite data types in JavaScript include arrays and objects.
 Variables point to values stored in memory and are declared using
the const , let or var keywords.
 Values are assigned to variables using the = operator.
 The value of any variables declared using const can’t be changed.
 You can reassign values to variables declared using let or var .
 Alert, prompt and confirm boxes can be used to add some interaction between a
web page and the user.
Chapter 3

 Strings are collections of characters that are used to show blocks of text in
JavaScript.
 Special values can beescapedby placing a backslash ( \ ) in front of them.
 Strings have various properties and methods that provide information about
them.
 The length property tells us how many characters there are in a string.
 Strings can beconcatenated(joined together) using the + operator.
 Template literals are like superpowered strings, allowing JavaScript code to be
inserted into a string.
Chapter 4

 integers and floats


 numeric literals
 exponential notation
 arithmetical operations
 varying variables
 converting between numbers and strings
 random numbers
 Numbers can be integers such as 2 or floats (decimals) such as 7.8, although
JavaScript doesn’t differentiate between them and just has a single primitive data
type of Number .
 Numbers can be written in exponential notation such as 5e6 for five million.
 The arithmetic operations +, -, *, / and % can be applied to any two numbers.
 It’s possible to change strings to numbers and vice versa.
 If you try to perform operations between a string and a number, JavaScript will
attempt to convert the type to complete the operation. This can cause some
inconsistent and unexpected results!
 A random number between 0 and 1 is returned by the Math.random() method.

chapter 5

Programming languages use a variety of different data structures to store values, but
one of the most common is an array.
In this chapter, we’ll be covering the following:

 creating arrays
 adding values to arrays
 removing values from arrays
 the spread operator
 multi-dimensional arrays

 Arrays are an ordered list of values.


 An array literal is written using square brackets containing comma-separated
values—such as [2,3,5,7] .
 Arrays can contain any type of value—even other arrays!
 The index is used to reference a specific item in an array. For
example, myArray[0] refers to the first item in myArray .
 Multi-dimensional arrays are arrays that contain other arrays.
 Arrays have many methods that can be used to add, remove and manipulate
items in the array.
 The spread operator is used by placing an ellipsis of three dots in front of an
array. It has the effect of taking all the values out of the array and listing them as
separate values inside a new array.

Chapter 6

 Booleans are primitive values that can only be true or false .


 All values have an inherent Boolean value of true or false .
 Truthy values are values that have a Boolean value of true . Most values are
truthy.
 Falsy values have a Boolean value of false . The values that are falsy vary in
different languages. There are nine falsy values in JavaScript.
 Negation makes truthy values false and falsy values true. Double negation
returns a value’s Boolean value.
 Logical operators such as AND and OR can be used to combine multiple
statements.
 Values can be compared to see if they’re equal, greater than or less than other
values.
 A conditional statement can be used to control the flow of a program based on a
condition.
 The ternary operator is a concise way of writing an if–else statement in a single
line of code.
 A switch statement can be used when there are multiple options.
Chapter 7

 A loop is a block of code that runs over and over again until a certain condition is
met.
 An infinite loop is a loop that never stops, as it’s impossible to meet the condition
for breaking out of the loop.
 A while loop will continue to run as long as a particular condition is true.
 A do–while loop will also run while a condition is true, but the condition comes at
the end, rather than the beginning of the loop.
 A for loop sets the initial value, a condition for stopping, and increment at the
start, and then runs a block of code until the condition is met. After every loop, the
increment instruction is carried out.
 Nested loops can be formed by running a loop within another loop. The inner
loop runs all the way through foreverypass of the outer loop.

You might also like