diff --git a/snippets/equals.md b/snippets/equals.md index 05659ec4e..d94bb88ad 100644 --- a/snippets/equals.md +++ b/snippets/equals.md @@ -23,4 +23,5 @@ const equals = (a, b) => { ```js equals({ a: [2, { e: 3 }], b: [4], c: 'foo' }, { a: [2, { e: 3 }], b: [4], c: 'foo' }); // true +equals([ 1, 2, 3 ], { 0: 1, 1: 2, 2: 3 }); // true ``` diff --git a/snippets/getType.md b/snippets/getType.md index da4b259c7..9b38bd64d 100644 --- a/snippets/getType.md +++ b/snippets/getType.md @@ -5,14 +5,14 @@ tags: type,beginner Returns the native type of a value. -Return `"undefined"` or `"null"` if the value is `undefined` or `null`. -Otherwise, use `Object.prototype.constructor.name` to get the name of the constructor, `String.prototype.toLowerCase()` to return it in lowercase. +Return `'undefined'` or `'null'` if the value is `undefined` or `null`. +Otherwise, use `Object.prototype.constructor.name` to get the name of the constructor. ```js const getType = v => - v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase(); + v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name; ``` ```js -getType(new Set([1, 2, 3])); // 'set' +getType(new Set([1, 2, 3])); // 'Set' ``` diff --git a/snippets/isArrayLike.md b/snippets/isArrayLike.md index 2fe61e0f7..badab6686 100644 --- a/snippets/isArrayLike.md +++ b/snippets/isArrayLike.md @@ -12,7 +12,8 @@ const isArrayLike = obj => obj != null && typeof obj[Symbol.iterator] === 'funct ``` ```js +isArrayLike([1, 2, 3]); // true isArrayLike(document.querySelectorAll('.className')); // true isArrayLike('abc'); // true isArrayLike(null); // false -``` \ No newline at end of file +``` diff --git a/snippets/isNil.md b/snippets/isNil.md index 8d7520991..637baa7c4 100644 --- a/snippets/isNil.md +++ b/snippets/isNil.md @@ -14,4 +14,5 @@ const isNil = val => val === undefined || val === null; ```js isNil(null); // true isNil(undefined); // true +isNil(''); // false ``` diff --git a/snippets/isPrimitive.md b/snippets/isPrimitive.md index 1840f8d95..99c14fb5b 100644 --- a/snippets/isPrimitive.md +++ b/snippets/isPrimitive.md @@ -13,9 +13,11 @@ const isPrimitive = val => Object(val) !== val; ```js isPrimitive(null); // true +isPrimitive(undefined); // true isPrimitive(50); // true isPrimitive('Hello!'); // true isPrimitive(false); // true isPrimitive(Symbol()); // true isPrimitive([]); // false -``` \ No newline at end of file +isPrimitive({}); // false +```