Skip to content

Instantly share code, notes, and snippets.

/string/ --> matches the full string

/string/i --> case insenstive match

/string|anotherstring/ --> matches to all options

.test() --> returns a boolean

.match() --> returns the matched strings

@bayfera
bayfera / callbindapply.md
Last active March 14, 2020 09:09
call bind apply in JavaScript

call bind and apply: are methods that can be used to assign an object to the this keyword

When a function uses the this keyword in its body, its value can be bound to a particular object during the call using the call and apply methods.

Example 1

function add(c,d){
  return this.a + this.b + c + d;
}
@bayfera
bayfera / destructuring.js
Created January 19, 2020 10:01 — forked from mikaelbr/destructuring.js
Complete collection of JavaScript destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];