This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
import test from 'ava'; | |
let promise1; | |
let promise2; | |
let promise3; | |
let promises; | |
test.beforeEach(() => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function f1WithoutUseStrict() { | |
return this; | |
} | |
function f1WithUseStrict() { | |
'use strict'; | |
return this; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const result = Array.from({ length: 3 }, (elt, index) => index); | |
result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const person = { | |
name: 'ahmehri', | |
age: 29, | |
} | |
const key = 'age'; | |
const { [key]: destructuredAge } = person; | |
destructuredAge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const _ = require('lodash'); | |
const obj1 = { entities: { jobs: { 1: 1 }, source: 'obj1' } }; | |
const obj2 = { entities: { jobs: { 1: 3 } }}; | |
const merge = { ...obj1, ...obj2}; | |
merge | |
const mergeWithLodash = _.merge({}, obj1, obj2); | |
mergeWithLodash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let result; | |
let value; | |
result = { | |
value | |
}; | |
// how to avoid the following result, adding a property to an object | |
// if it's value is undefined? | |
result; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const msg = 'test'; | |
const test1 = 'test1'; | |
const regex = /test/; | |
console.log(regex.test(msg)); | |
const regex1 = `/${msg}/`; | |
// console.log(regex1.test(msg)) // regex1.test is not a function | |
const regex3 = /`${msg}$`/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const _ = require('lodash'); | |
const array1 = [1, 2]; | |
const array2 = [1, 2]; | |
const result = array1 === array2; | |
result | |
console.log([] === []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const _ = require('lodash'); | |
function customizer(objValue, srcValue) { | |
if (_.isArray(objValue)) { | |
return srcValue; | |
} | |
} | |
var object = { ids: [1] }; | |
var other = { ids: [] }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const queryString = require('query-string'); | |
const result = queryString.stringify({ name: 'ahmed', items: [1] }); | |
result; | |
const arrayFormat = queryString.stringify( | |
{ name: 'ahmed', items: [1] }, | |
{ arrayFormat: 'bracket' } | |
); | |
arrayFormat; |
OlderNewer