Javascript Syntax: Intro Flashcards
console.log()
The console.log() method is used to log or print messages to the console. It can also be used to print objects and other info.
JavaScript
JavaScript is a programming language that powers the dynamic behavior on most websites. Alongside HTML and CSS, it is a core technology that makes the web run.
Methods
Methods return information about an object, and are called by appending an instance with a period ., the method name, and parentheses.
Libraries
Libraries contain methods that can be called by appending the library name with a period ., the method name, and a set of parentheses.
Numbers
Numbers are a primitive data type. They include the set of all integers and floating point numbers.
String .length
The .length property of a string returns the number of characters that make up the string.
Data Instances
When a new piece of data is introduced into a JavaScript program, the program keeps track of it in an instance of that data type. An instance is an individual case of a data type.
Booleans
Booleans are a primitive data type. They can be either true or false.
Math.random()
The Math.random() function returns a floating-point, random number in the range from 0 (inclusive) up to but not including 1.
Math.floor()
The Math.floor() function returns the largest integer less than or equal to the given number.
Single Line Comments
In JavaScript, single-line comments are created with two consecutive forward slashes //.
Null
Null is a primitive data type. It represents the intentional absence of value. In code, it is represented as null.
Strings
Strings are a primitive data type. They are any grouping of characters (letters, spaces, numbers, or symbols) surrounded by single quotes ‘ or double quotes “.
Arithmetic Operators
JavaScript supports arithmetic operators for:
\+ addition - subtraction * multiplication / division % modulo
Multi-line Comments
In JavaScript, multi-line comments are created by surrounding the lines with /* at the beginning and */ at the end. Comments are good ways for a variety of reasons like explaining a code block or indicating some hints, etc.