Javascript Cheat Sheet Github



  1. Javascript Cheat Sheet Github Example
  2. Javascript Cheat Sheet Github 2
  3. Reverse Shell Cheat Sheet Github
  4. Javascript Cheat Sheet Github Full
  5. Github Search Cheat Sheet
  6. Github Commands Cheat Sheet

Git; HTML Cheat-sheet Forms. JavaScript Cheat-sheet Arrays. Array.from(arrayLike, mapFn, thisArg) creates mapped array from array-like iterable object. JavaScript RegExp bookđź”—. Visit my repo learnjsregexp for details about the book I wrote on JavaScript regular expressions. The ebook uses plenty of examples to explain the concepts from the basics and includes exercises to test your understanding. The cheatsheet and examples presented in this post are based on contents of this book. Musa Al-hassy March 12, 2020 JavaScript CheatSheet JavaScript is what everyone calls the language, but that name is trademarked (by Oracle, which inherited the trademark from Sun). Therefore, the official name of JavaScript is ECMAScript. Javascript OO Cheat Sheet. GitHub Gist: instantly share code, notes, and snippets.

Above diagram created using Regulex


This blog post gives an overview of regular expression syntax and features supported by JavaScript. Examples have been tested on Chrome/Chromium console (version 81+) and includes features not available in other browsers and platforms. Assume ASCII character set unless otherwise specified. This post is an excerpt from my JavaScript RegExp book.

Elements that define a regular expressionđź”—

NoteDescription
MDN: Regular ExpressionsMDN documentation for JavaScript regular expressions
/pat/a RegExp object
const pet = /dog/save regexp in a variable for reuse, clarity, etc
/pat/.test(s)Check if given pattern is present anywhere in input string
returns true or false
iflag to ignore case when matching alphabets
gflag to match all occurrences
new RegExp('pat', 'i')construct RegExp from a string
second argument specifies flags
use backtick strings with ${} for interpolation
sourceproperty to convert RegExp object to string
helps to insert a RegExp inside another RegExp
flagsproperty to get flags of a RegExp object
s.replace(/pat/, 'repl')method for search and replace
s.search(/pat/)gives starting location of the match or -1
s.split(/pat/)split a string based on regexp
AnchorsDescription
^restricts the match to start of string
$restricts the match to end of string
mflag to match the start/end of line with ^ and $ anchors
r, n, u2028 and u2029 are line separators
dos-style files use rn, may need special attention
brestricts the match to start/end of words
word characters: alphabets, digits, underscore
Bmatches wherever b doesn't match

^, $ and are metacharacters in the above table, as these characters have special meaning. Prefix a character to remove the special meaning and match such characters literally. For example, ^ will match a ^ character instead of acting as an anchor.

FeatureDescription
pat1|pat2|pat3multiple regexp combined as OR conditional
each alternative can have independent anchors
(pat)group pattern(s), also a capturing group
a(b|c)dsame as abd|acd
(?:pat)non-capturing group
(?<name>pat)named capture group
.match any character except line separators
[]Character class, matches one character among many
Greedy QuantifiersDescription
?match 0 or 1 times
*match 0 or more times
+match 1 or more times
{m,n}match m to n times
{m,}match at least m times
{n}match exactly n times
pat1.*pat2any number of characters between pat1 and pat2
pat1.*pat2|pat2.*pat1match both pat1 and pat2 in any order

Greedy here means that the above quantifiers will match as much as possible that'll also honor the overall regexp. Appending a ? to greedy quantifiers makes them non-greedy, i.e. match as minimally as possible. Quantifiers can be applied to literal characters, groups, backreferences and character classes.

Character classDescription
[ae;o]match any of these characters once
[3-7]range of characters from 3 to 7
[^=b2]negated set, match other than = or b or 2
[a-z-]- should be first/last or escaped using to match literally
[+^]^ shouldn't be first character or escaped using
[]]] and should be escaped using
wsimilar to [A-Za-z0-9_] for matching word characters
dsimilar to [0-9] for matching digit characters
ssimilar to [ tnrfv] for matching whitespace characters
use W, D, and S for their opposites respectively
uflag to enable unicode matching
p{}Unicode character sets
P{}negated unicode character sets
see MDN: Unicode property escapes for details
u{}specify unicode characters using codepoints
LookaroundsDescription
lookaroundsallows to create custom positive/negative assertions
zero-width like anchors and not part of matching portions
(?!pat)negative lookahead assertion
(?<!pat)negative lookbehind assertion
(?=pat)positive lookahead assertion
(?<=pat)positive lookbehind assertion
variable length lookbehind is allowed
(?!pat1)(?=pat2)multiple assertions can be specified next to each other in any order
as they mark a matching location without consuming characters
((?!pat).)*Negates a regexp pattern
Matched portionDescription
m = s.match(/pat/)assuming g flag isn't used and regexp succeeds,
returns an array with matched portion and 3 properties
index property gives the starting location of the match
input property gives the input string s
groups property gives dictionary of named capture groups
m[0]for above case, gives entire matched portion
m[N]matched portion of Nth capture group
s.match(/pat/g)returns only the matched portions, no properties
s.matchAll(/pat/g)returns an iterator containing details for
each matched portion and its properties
Backreferencegives matched portion of Nth capture group
use $1, $2, $3, etc in replacement section
$& gives entire matched portion
$` gives string before the matched portion
$' gives string after the matched portion
use 1, 2, 3, etc within regexp definition
$$insert $ literally in replacement section
$0Nsame as $N, allows to separate backreference and other digits
Nxhhallows to separate backreference and digits in regexp definition
(?<name>pat)named capture group
use k<name> for backreferencing in regexp definition
use $<name> for backreferencing in replacement section
Javascript cheat sheet github 2

Regular expression examplesđź”—

  • test method
  • new RegExp() constructor
  • string and line anchors
  • replace method and word boundaries
  • alternations and grouping
  • MDN: Regular Expressions doc provides escapeRegExp function, useful to automatically escape metacharacters.
    • See also XRegExp utility which provides XRegExp.escape and XRegExp.union methods. The union method has additional functionality of allowing a mix of string and RegExp literals and also takes care of renumbering backreferences.
  • dot metacharacter and quantifiers
  • match method
  • matchAll method
  • function/dictionary in replacement section
  • split method
  • backreferencing with normal/non-capturing/named capture groups
Javascript cheat sheet github 2017
  • examples for lookarounds

Javascript Cheat Sheet Github Example

Debugging and Visualization toolsđź”—

As your regexp gets complicated, it can get difficult to debug if you run into issues. Download an9g2i driver. Building your regexp step by step from scratch and testing against input strings will go a long way in correcting the problem. To aid in such a process, you could use various online regexp tools.

regex101 is a popular site to test your regexp. You'll have first choose the flavor as JavaScript. Then you can add your regexp, input strings, choose flags and an optional replacement string. Matching portions will be highlighted and explanation is offered in separate panes. There's also a quick reference and other features like sharing, code generator, quiz, etc.

Another useful tool is jex: regulex which converts your regexp to a rail road diagram, thus providing a visual aid to understanding the pattern.

JavaScript RegExp bookđź”—

Visit my repo learn_js_regexp for details about the book I wrote on JavaScript regular expressions. The ebook uses plenty of examples to explain the concepts from the basics and includes exercises to test your understanding. The cheatsheet and examples presented in this post are based on contents of this book.

If you have ever worked in web development or in any Software development, then you must have heard of Git, or most probably you have used or using git because it is one of the best version control systems we have. The website GitHub use git version control as its brain. Git provides the best way to manage your project, and it became more helpful when a proper team is working on a project.

Git comes with a standard Command Line Interface (CLI), which mean to interact or work with Git we need to pass commands, though if we are using GitHub for our project rather than using git commands we simply use GitHub buttons and other option to manage our project but it is not necessary that if we are using Git we are using GitHub too, Git and GitHub are two separate entities. Many Developers find using a CLI intriguing because it makes them happy to interact with command lines or terminal or white text on black console, but for a beginner using a command line for git commands becomes a daunting task. Git contains hundreds of commands and it is impossible to learn each of them, so what we do, we just simply learn and practice only those commands which are common and enough to serve our purpose.

So here we have provided a cheat sheet for Git commands, so, you could muddle through if you get stuck somewhere using git or forget some commands.

What is Git?

Git is an open-source distributed version control system and the working principle behind the GitHub website. It is the most famous and widely used version control system of this decade which has huge community support. It is called the Distributed Version control system because, unlike other version control systems that store the project’s full version history in one place, Git allows each developer to have their own local repository with complete proper history changes.

What is Version Control?

Sheet

A version control system is a software that keeps track of your project history and version. Download nec pci to usb enhanced host controller (b1) driver.

Git Terminologies

Before reading the git cheat sheet let’s have the look at the basic terminologies we use in git:

TerminologyDescription
BranchA branch represents the various versions and repositories branching out from your main project. It helps us to keep track of the changes happening in the various repositories.
CommitCommit is used to save some changes.
CheckoutWhen we switch between branches we use checkout command.
FetchFetch commands can copy and download the branch file to your local device.
ForkA fork is a copy of a repository.
HeadThe commit at the tip of a branch is called the head. It represents the most current commit of the repository you’re currently working in
IndexIf we make any changes in the project in order to save those changes we need to commit them, if not all those changes will remain in the index for commit.
MasterThe main branch of the repositories.
MergeIf one branch made any changes so, we can use the merge command to make that same changes in all other repositories
OriginThe default version of a repository
PullIt represents the suggestion for changes to the master branch
PushIt is used to update the remote branch if we have committed the changes
RepositoryIt holds all the project’s files
TagIt tracks the important commits

Git Cheat Sheet

Git Configuration

Javascript Cheat Sheet Github 2

CommandsDescription
git config –-global user.name “User Name”Attach the name User Name to the commits and tag
git config –global user.email “email address”Attach the email address to the commits and tags
git config –global color.ui autoEnable some colorization in Git interface

Reverse Shell Cheat Sheet Github

Git Setting Project

CommandsDescription
git init [project name]This command will create a new repository if the project name is provided else it will initialize the git in the current directory.
git clone [project url]It will create a clone of the project which is at remote repository project URL

Git Frequent used commands

CommandsDescription
git statusShow the status of the repository
git diff [File]Show changes between the working directory and staging area
git diff –stages [file]Show changes between the staging area and index
git checkout — [file]Discard change in the working directory
git add [file]Add new file
git reset [file]Get the file back from the staging area
git commitSave the changes
git rm [file]Remove the file
git stashPut the changes into stash

Git Branching

Node
CommandsDescription
git branch [-a]It will show all the branches of the local repository her –a mean all
git branch [branchname]Create a new branch
git checkout [-b] [name]Switch to name branch, if name is not a branch in the repository so create new branch.
git merge [branch]Merge the branch
git branch –d [branch name]Remove the branch

Javascript Cheat Sheet Github Full

Review Work

Github Search Cheat Sheet

CommandsDescription
git log [-n count]List last n numbers of commit history
git log –oneline –graph –decorateGive Overview along with reference label and history graph.
git log ref. .List current branch commits
git reflogList operations such as commits, checkout, etc.

Git Tag

CommandsDescription
git tagShow all tags
git tag [name] [commit sha]Create a tag reference named name for current commit
git tag –d [name]Remove the tag

Revert Changes

Github commands cheat sheet
CommandsDescription
git reset [–hard] [target reference]Switch current branch to the target reference, and leaves a difference as an uncommitted change.
git revert [commit sha]Create a new commit, reverting changes from the specified commit.

Synchronizing Repositories

CommandsDescription
git fetch [remote]Fetch the changes from remote
git pull [remote]Fetch the changes and merge the current branch with upstream
git push [remote]Push all the changes to the remote
git push –u [remote] [branch]Push the local branch to the remote upstream

Conclusion

Git has hundreds of commands and to learn each command is impossible so we only use those commands which are basic and necessary for our project point of view. All the git commands we have provided in this article are the most important git commands and every interviewer expects, you to know at least these commands.

Github Commands Cheat Sheet

If you like this article or have any suggestion related to the git cheat sheet, please let us know by filling the comment box.

You may be also interested in: