Same as for a variable identifier: it must start with a
letter, underscore or dollar sign
and can contain alphabetic, numeric, or underscore characters. const prefix = '212';
Events in javascript
The building blocks of an interactive web page is the JavaScript event system. An event in JavaScript is something that happens with or on the webpage. A few example of events: A mouse click The webpage loading Mousing over a hot spot on the webpage, also known as hovering Selecting an input box in an HTML form A keystroke
Numbers and dates
Decimal numbers 0888 // 888 parsed as decimal Binary numbers Octal numbers Hexadecimal numbers The built-in Math object has properties and methods for mathematical constants and functions. Math.PI Math.sin(1.56)
Text formatting
JavaScript's String type is used to represent textual data 'foo' "bar" The String object is a wrapper around the string primitive data type. var s = new String("foo"); // Creates a String object console.log(s); // Displays: { '0': 'f', '1': 'o', '2': 'o'} typeof s; // Returns 'object'
The DateTimeFormat object is useful for formatting date and time. var msPerDay = 24 * 60 * 60 * 1000;
Regular Expressions
Regular expressions are patterns used to match character combinations in strings. In JavaScript, regular expressions are also objects. These patterns are used with the exec and test methods of RegExp, and with the match, replace, search, and split methods of String.
Indexed collections
An array is a set of values that you refer to with a name and an index. var arr = new Array(element0, element1, ..., elementN); An array is a variable that can store many variables within it. Creating an array is slightly different from creating a normal variable. Because JavaScript has variables and properties associated with arrays, you have to use a special function to create a new array.
var myArray = new Array();
myArray[0] = "Football"; myArray[1] = "Baseball"; myArray[2] = "Cricket";
Keyed collections
Map and Set objects contain elements which are iterable in the order of insertion.
Working with objects
An object is a collection of properties, and a property is an association between a name (or key) and a value
Iterators and generators
An object is an iterator when it knows how to access items from a collection one at a time, while keeping track of its current position within that sequence.
Exception Handling
Strict mode enables more warnings and makes JavaScript a cleaner language (nonstrict mode is sometimes called sloppy mode).
Javascript has a lot of inbuilt methods you can use to get the date and time. document.write( the_date + "<BR>"); Date( year, month, day [, hour, minute, second, millisecond ] ) To get the year, add getFullYear to the end of your date object. Like this: var the_date = new Date(); var year = the_date.getFullYear(); document.write(year + "<BR>"); To get the month of the year, use getMonth: var month = the_date.getMonth(); document.write( month + "<BR>");
JavaScript objects can be thought of as simple collections of name-value pairs. As such, they are similar to dictionaries in Python and hash tables in C and C++
A JavaScript is a library of pre-written JavaScript which allows for easier development of JavaScript-based applications, especially for AJAX and other web-centric technologies.
A modal is a dialog box/popup window that is displayed on top of the current page, created with html, css and javascript.