# The JavaScript Cookbook

> A collection of practical JavaScript how-to articles covering common tasks with strings, numbers, dates, objects, arrays, functions and loops.

Author: Flavio Copes | Published: 2018-08-01 | Updated: 2019-04-29 | Canonical: https://flaviocopes.com/javascript-cookbook/

> Note: this is a living document. Over time this post will fill up with tons of useful how-tos

## Strings

- [How to uppercase the first letter of a string in JavaScript](https://flaviocopes.com/how-to-uppercase-first-letter-javascript/)
- [How to check if a string contains a substring in JavaScript](https://flaviocopes.com/how-to-string-contains-substring-javascript/)
- [How to replace all occurrences of a string in JavaScript](https://flaviocopes.com/how-to-replace-all-occurrences-string-javascript/)
- [How to convert a string to a number in JavaScript](https://flaviocopes.com/how-to-convert-string-to-number-javascript/)
- [How to create a multiline string in JavaScript](https://flaviocopes.com/how-to-create-multiline-string-javascript/)
- [How to check if a string starts with another in JavaScript](https://flaviocopes.com/how-to-check-string-starts-with/)

## Numbers

- [How to trim the leading zero in a number in JavaScript](https://flaviocopes.com/how-to-trim-leading-zero-number/)
- [How to format a number as a currency value in JavaScript](https://flaviocopes.com/how-to-format-number-as-currency-javascript/)
- [How to generate a random number between two numbers in JavaScript](https://flaviocopes.com/how-to-generate-random-number-between/)

## Dates

- [How to get the current timestamp in JavaScript](https://flaviocopes.com/how-to-get-timestamp-javascript/)

## Objects

- [How to remove a property from a JavaScript object](https://flaviocopes.com/how-to-remove-object-property-javascript/)
- [How to inspect a JavaScript object](https://flaviocopes.com/how-to-inspect-javascript-object/)
- [How to deep clone a JavaScript object](https://flaviocopes.com/how-to-clone-javascript-object/)
- [How to check if a JavaScript object property is undefined](https://flaviocopes.com/how-to-check-undefined-property-javascript/)
- [How to merge two objects in JavaScript](https://flaviocopes.com/how-to-merge-objects-javascript/)
- [How to access a method of an object dynamically in JavaScript](https://flaviocopes.com/javascript-dynamic-method/)
- [How to use the destructuring syntax to work with arrays and objects in JavaScript](https://flaviocopes.com/javascript-destructuring/)
- [How to count the number of properties in a JavaScript object](https://flaviocopes.com/how-to-count-properties-object-javascript/)
- [How to list all methods of an object in JavaScript](https://flaviocopes.com/how-to-list-object-methods-javascript/)

## Arrays

- [How to remove an item from an Array in JavaScript](https://flaviocopes.com/how-to-remove-item-from-array/)
- [How to append an item to an array in JavaScript](https://flaviocopes.com/how-to-append-item-to-array/)
- [How to initialize a new array with values in JavaScript](https://flaviocopes.com/how-to-initialize-array-with-values/)
- [How to use Async and Await with Array.map()](https://flaviocopes.com/javascript-async-await-array-map/)
- [How to empty a JavaScript array](https://flaviocopes.com/how-to-empty-javascript-array/)
- [How to sort an array of objects by a property value in JavaScript](https://flaviocopes.com/how-to-sort-array-of-objects-by-property-javascript/)
- [How to get the unique properties of a set of objects in a JavaScript array](https://flaviocopes.com/how-to-get-unique-properties-of-object-in-array/)

## Functions

- [How to set default parameter values in JavaScript](https://flaviocopes.com/how-to-set-default-parameter-values-javascript/)

## Loops

- [How to get the index of an iteration in a for-of loop in JavaScript](https://flaviocopes.com/how-to-get-index-in-for-of-loop/)
