https://www.browserling.com/ gives you the ability to Live interactive cross-browser testing.
shallow copy vs deep copy
peek vs pop
In the course of normal queue operations, when an element is removed from a queue, that element is always the first element that was inserted into the queue. There are certain applications of queues, however, that require that elements be removed in an order other than first-in, first-out. When we need to simulate such an application, we need to create a data structure called a priority queue.
The linked list can be used in almost every situation where a one-dimensional array is used, except when you need random access to the elements of a list. When random access is required, an array is the better data structure to use.
A circularly linked list
Hashing is a common technique for storing data in such a way that the data can be inserted and retrieved very quickly. Hashing uses a data structure called a hash table. Although hash tables provide fast insertion, deletion, and retrieval, they perform poorly for operations that involve searching, such as finding the minimum and maximum values in a data set. For these operations, other data structures such as the binary search tree are more appropriate.
Bubble sort in action
The Quicksort algorithm is best to use on large datasets; its performance degrades for smaller data sets.
There are two ways to search for data in a list: sequential search and binary search. A sequential search is used when the items in a list are in random order; a binary search is used when the items in a list are in sorted order. Binary search is the more efficient algorithm, but you also have to take into account the extra time it takes to sort the data set before being able to search it for a value.
When a function is stored as a property of an object, we call it a method.
We can use functions and closure to make modules. A module is a function or object that presents an interface but that hides its state and implementation.
// numbers is [‘zero’, ‘one’, undefined, ‘shi’, ‘go’]
deleting some number of elements and replacing them with other elements. The first argument is an ordinal in the array. The second argument is the number of elements to delete. Any additional arguments get inserted into the array at that point:
// numbers is [‘zero’, ‘one’, ‘shi’, ‘go’]
The property whose value is ‘shi’ has its key changed from ‘4’ to ‘3’ . Because every property after the deleted property must be removed and reinserted with a new key, this might not go quickly for large arrays.
CommonJs: synchronous require
This style uses a synchronous require method to load a dependency and return an exported interface. A module can specify exports by adding properties to the exports object or setting the value of module.exports.
AMD: asynchronous require
Asynchronous Module Definition
Other module systems (for the browser) had problems with the synchronous require (CommonJS) and introduced an asynchronous version (and a way to define modules and exporting values):
These global properties return a simple value; they have no properties or methods.
When you want to know whether a pattern is found in a string, use the test or search method; for more information (but slower execution) use the exec or match methods.
Map, Keyed Collections
The WeakMap object is a collection of key/value pairs in which the keys are objects only and the values can be arbitrary values. The object references in the keys are held weakly meaning that they are target of garbage collection (GC) if there is no other reference to the object anymore. The WeakMap API is the same as the Map API.
Checking whether an element exists in an collection using indexOf for arrays is slow.
Set objects let you delete elements by their value. With an array you would have to splice based on a element’s index.
The value NaN cannot be found with indexOf in array.
Set objects store unique values, you don’t have to keep track of duplicates by yourself.
The use cases of WeakSet objects are limited. They will not leak memory so it can be safe to use DOM elements as a key and mark them for tracking
Functional programming sample
Functional programming, no mutation.