/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
/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
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;
}| // === Arrays | |
| var [a, b] = [1, 2]; | |
| console.log(a, b); | |
| //=> 1 2 | |
| // Use from functions, only select from pattern | |
| var foo = () => [1, 2, 3]; |