Leanpub Header

Skip to main content

Javascript Snippets

Secret Code Snippets used by Powerful Developers to create Innovative Apps

Even if you are a JS beginner, this book elevates your JS game !! Take your JS understanding to the next level by studying and implementing the code snippets from this book in your own projects.

The author is letting you choose the price you pay for this book!

Pick Your Price...
PDF
EPUB
WEB
201
Pages
About

About

About the Book

This book is for anyone with a basic working understanding of JS.

 

It covers 9 chapters with innovative and interesting ways of solving common situations when working with Arrays, Objects, NodeJS, Functions, Browser and more.

 

The idea is for you to also use some of the snippets as plug and play functions in your projects.

 

Why learn in this way ? 

 

Javascript is one of the most versatile and powerful programming languages, learning the basics and using libraries like Jquery is really easy, however most of the time the solutions to the problems we face might be coded in a simpler and more efficient way.

 

This book serves as a reference guide providing code snippets written in an efficient way, by studying each of them, and even customizing some of the snippets to better suit your project you will get in the habit of writing code like a god.

 

If you really want to develop a mindset which allows you to code in a precise and fast way, then there’s no escape. You must understand the idea behind each snippet and implement it on a project, by having the experience and solving all the challenges you face you will become a successful developer.

Check out other books from the author:

Javascript Snippets

Appwrite Up and Running

Front End Developer Interview Questions

ReactJS Documentation

Backend Developer Interview Questions

VueJS Documentation

React Redux Documentation

DevOPs

Data Science Workflow for Beginners

Share this book

Price

Pick Your Price...

Minimum price

$9.99

$19.99

You pay

$19.99

Author earns

$15.99
$

All prices are in US $. You can pay in US $ or in your local currency when you check out.

EU customers: prices exclude VAT, which is added during checkout.

...Or Buy With Credits!

Number of credits (Minimum 1)

1
The author will earn $12.00 from your purchase!
You can get credits monthly with a Reader Membership

Author

About the Author

A.J. García

I started my coding career back in 2003. Lately I've been involved a lot in Javascript for frontend and the backend.

I would love passing along to you some of the experiences and challenges I've faced over the years.

Contents

Table of Contents

Introduction

  1. The Unique Advantage this Book will allow you to unleash
  2. Who is this book for ?
  3. What is covered in this book ?

Chapter 1: Array related snippets

  1. all
  2. allEqual
  3. any
  4. compact
  5. difference
  6. drop
  7. dropRight
  8. everyNth
  9. filterNonUnique
  10. findLast
  11. head
  12. includesAll
  13. includesAny
  14. initial
  15. last
  16. maxN
  17. minN
  18. none
  19. nthElement
  20. offset
  21. reject
  22. sample
  23. similarity
  24. tail
  25. take
  26. union
  27. uniqueElements
  28. without
  29. arrayToCSV
  30. bifurcate
  31. bifurcateBy
  32. chunk
  33. chunkIntoN
  34. countBy
  35. countOccurrences
  36. deepFlatten
  37. differenceBy
  38. differenceWith
  39. dropRightWhile
  40. dropWhile
  41. filterNonUniqueBy
  42. findLastIndex
  43. flatten
  44. forEachRight
  45. frequencies
  46. groupBy
  47. haveSameContents
  48. indexOfAll
  49. initialize2DArray
  50. initializeArrayWithRange
  51. initializeArrayWithRangeRight
  52. initializeArrayWithValues
  53. initializeNDArray
  54. intersection
  55. intersectionBy
  56. intersectionWith
  57. isContainedIn
  58. isSorted
  59. join
  60. longestItem
  61. mapObject
  62. mostFrequent
  63. normalizeLineEndings
  64. partition
  65. pull
  66. reduceSuccessive
  67. reduceWhich
  68. reducedFilter
  69. remove
  70. sampleSize
  71. shank
  72. shuffle
  73. sortedIndex
  74. sortedIndexBy
  75. sortedLastIndex
  76. sortedLastIndexBy
  77. stableSort
  78. symmetricDifference
  79. symmetricDifferenceBy
  80. symmetricDifferenceWith
  81. takeRight
  82. takeRightWhile
  83. takeWhile
  84. toHash
  85. unionBy
  86. unionWith
  87. uniqueElementsBy
  88. uniqueElementsByRight
  89. uniqueSymmetricDifference
  90. unzip
  91. xProd
  92. zip
  93. zipObject
  94. JSONtoCSV
  95. permutations
  96. pullAtIndex
  97. pullAtValue
  98. pullBy
  99. unzipWith
  100. weightedSample
  101. zipWith

Chapter 2: Browser related snippets

  1. createElement
  2. currentURL
  3. getImages
  4. getBaseURL
  5. getStyle
  6. hasClass
  7. hide
  8. insertAfter
  9. insertBefore
  10. isBrowserTabFocused
  11. nodeListToArray
  12. redirect
  13. setStyle
  14. show
  15. toggleClass
  16. UUIDGeneratorBrowser
  17. arrayToHtmlList
  18. bottomVisible
  19. detectDeviceType
  20. elementContains
  21. formToObject
  22. getScrollPosition
  23. getURLParameters
  24. httpDelete
  25. httpGet
  26. httpPost
  27. httpPut
  28. httpsRedirect
  29. isBrowser
  30. off
  31. on
  32. parseCookie
  33. prefersDarkColorScheme
  34. prefersLightColorScheme
  35. prefix
  36. recordAnimationFrames
  37. scrollToTop
  38. serializeCookie
  39. serializeForm
  40. smoothScroll
  41. supportsTouchEvents

Chapter 3: Date related snippets

  1. dayOfYear
  2. getMeridiemSuffixOfInteger
  3. isAfterDate
  4. isBeforeDate
  5. isLeapYear
  6. isSameDate
  7. isWeekday
  8. isWeekend
  9. maxDate
  10. minDate
  11. getColonTimeFromDate
  12. formatDuration
  13. getDaysDiffBetweenDates
  14. tomorrow
  15. yesterday

Chapter 4: Function related snippets

  1. checkProp
  2. functionName
  3. negate
  4. nthArg
  5. timeTaken
  6. unary
  7. ary
  8. attempt
  9. bind
  10. bindKey
  11. call
  12. chainAsync
  13. collectInto
  14. compose
  15. composeRight
  16. converge
  17. curry
  18. debounce
  19. defer
  20. delay
  21. flip
  22. hz
  23. mostPerformant
  24. once
  25. over
  26. overArgs
  27. partial
  28. partialRight
  29. pipeAsyncFunctions
  30. pipeFunctions
  31. promisify
  32. rearg
  33. runPromisesInSeries
  34. sleep
  35. spreadOver
  36. times
  37. uncurry
  38. unfold
  39. when
  40. throttle

Chapter 5: Math related snippets

  1. accumulate
  2. approximatelyEqual
  3. average
  4. celsiusToFahrenheit
  5. clampNumber
  6. digitize
  7. degreesToRads
  8. distance
  9. factorial
  10. fahrenheitToCelsius
  11. fibonacci
  12. gcd
  13. inRange
  14. isDivisible
  15. isEven
  16. isNegativeZero
  17. isOdd
  18. isPowerOfTwo
  19. isPrime
  20. lcm
  21. mapNumRange
  22. maxBy
  23. midpoint
  24. minBy
  25. powerset
  26. radsToDegrees
  27. randomHexColorCode
  28. randomIntegerInRange
  29. randomNumberInRange
  30. sum
  31. toDecimalMark
  32. toSafeInteger
  33. vectorAngle
  34. vectorDistance
  35. averageBy
  36. binomialCoefficient
  37. geometricProgression
  38. hammingDistance
  39. median
  40. percentile
  41. primes
  42. randomIntArrayInRange
  43. round
  44. sdbm
  45. standardDeviation
  46. sumBy
  47. sumPower
  48. toCurrency
  49. toOrdinalSuffix
  50. validateNumber
  51. luhnCheck

Chapter 6: Node related snippets

  1. atob
  2. btoa
  3. createDirIfNotExists
  4. untildify
  5. readFileLines
  6. JSONToFile
  7. colorize
  8. UUIDGeneratorNode
  9. hasFlags
  10. hashNode
  11. isDuplexStream
  12. isReadableStream
  13. isStream
  14. isTravisCI
  15. isWritableStream
  16. atob
  17. btoa
  18. createDirIfNotExists
  19. readFileLines
  20. untildify
  21. JSONToFile
  22. UUIDGeneratorNode
  23. colorize
  24. hasFlags
  25. hashNode
  26. isDuplexStream
  27. isReadableStream
  28. isStream
  29. isTravisCI
  30. isWritableStream

Chapter 7: Object related snippets

  1. objectFromPairs
  2. objectToEntries
  3. objectToPairs
  4. shallowClone
  5. bindAll
  6. deepClone
  7. deepFreeze
  8. deepGet
  9. defaults
  10. dig
  11. findKey
  12. findLastKey
  13. flattenObject
  14. forOwn
  15. forOwnRight
  16. functions
  17. get
  18. hasKey
  19. invertKeyValues
  20. lowercaseKeys
  21. mapKeys
  22. mapValues
  23. matches
  24. matchesWith
  25. merge
  26. nest
  27. objectToQueryString
  28. omit
  29. omitBy
  30. orderBy
  31. pick
  32. pickBy
  33. renameKeys
  34. size
  35. toPairs
  36. transform
  37. truthCheckCollection
  38. deepMapKeys
  39. equals
  40. unflattenObject

Chapter 8: Strings related snippets

  1. byteSize
  2. compactWhitespace
  3. containsWhitespace
  4. indentString
  5. isLowerCase
  6. isUpperCase
  7. mapString
  8. pad
  9. reverseString
  10. sortCharactersInString
  11. splitLines
  12. stripHTMLTags
  13. truncateString
  14. unescapeHTML
  15. CSVToArray
  16. RGBToHex
  17. capitalize
  18. capitalizeEveryWord
  19. decapitalize
  20. escapeHTML
  21. escapeRegExp
  22. extendHex
  23. fromCamelCase
  24. isAbsoluteURL
  25. isAnagram
  26. mask
  27. palindrome
  28. pluralize
  29. removeNonASCII
  30. toCamelCase
  31. toKebabCase
  32. toSnakeCase
  33. toTitleCase
  34. words
  35. yesNo
  36. CSVToJSON
  37. URLJoin
  38. hexToRGB
  39. prettyBytes
  40. stringPermutations

Chapter 9: Type related snippets

  1. castArray
  2. coalesce
  3. getType
  4. is
  5. isBoolean
  6. isEmpty
  7. isFunction
  8. isNil
  9. isNull
  10. isNumber
  11. isObject
  12. isObjectLike
  13. isString
  14. isSymbol
  15. isUndefined
  16. cloneRegExp
  17. coalesceFactory
  18. isArrayLike
  19. isPlainObject
  20. isPrimitive
  21. isPromiseLike
  22. isValidJSON

Bonus Projects

  1. Ecommerce Customer Satisfaction Project
  2. The data to work with
  3. The requirements
  4. Let’s build our script

Keep Exploring and Coding

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub