From c24d3126733cc08605f9c98dbd6ede102945c9ee Mon Sep 17 00:00:00 2001 From: laohan <120936337@qq.com> Date: Fri, 12 Oct 2018 15:12:43 +0800 Subject: [PATCH] Another primitive assert function --- snippets/isPrimitive.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/isPrimitive.md b/snippets/isPrimitive.md index 900d83d77..ebe691262 100644 --- a/snippets/isPrimitive.md +++ b/snippets/isPrimitive.md @@ -7,7 +7,7 @@ supplying the type using `typeof`. Since `typeof null` evaluates to `'object'`, it needs to be directly compared. ```js -const isPrimitive = val => !['object', 'function'].includes(typeof val) || val === null; +const isPrimitive = val => Object(val) !== val; ``` ```js