Get the App
SLTechnology News&Howtos  ›  Development  › 

How to understand the js object schema

Shulou Source: shulou.com Published: 2022-06-02 23:45:17 09月30日 Update

This article focuses on "how to understand the js object schema", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to understand the js object schema.

1. Matching object. If there is an ellipsis, the object can have more properties.

2. Detect only your own attributes (Object.keys) and ignore the attributes in the prototype. Object syntax supports special recognition attributes, fast attributes, and attributes do not support trailing commas.

Example

Test ("value object", () = > {let input ='{} 'let y = match (input) let v = y ({}) let w = y ({x: 0}) expect (v) .toEqual (true) expect (w) .toEqual (false)}) test ("object ELLIPSIS" () = > {let input ='{...} 'let y = match (input) let v = y ({}) let w = y ({x: 0}) let p = y ([]) expect (v) .toEqual (true) expect (w) .toEqual (true) expect (p) .toEqual (false)}) test ("object properties") () = > {let input ='{x} 'let y = match (input) let v = y ({x: 0}) let w = y ([null, 1]) expect (v) .toEqual (true) expect (w) .toEqual (false)}) test ("object properties ELLIPSIS", () = > {let input =' {x...} 'let y = match (input) let v = y ({x: 0) Y: 1}) let w = y ({}) expect (v) .toEqual (true) expect (w) .toEqual (false)}) test ("properties properties prop", () = > {let input ='{x input y} 'let y = match (input) let v = y ({x: 0) Y: 1}) let w = y ({}) expect (v) .toEqual (true) expect (w) .toEqual (false)}) test ("prop key value", () = > {let input ='{x:null} 'let y = match (input) let v = y ({x:null}) let w = y ([null]) 1]) expect (v) .toEqual (true) expect (w) .toEqual (false)}) test ("key QUOTE", () = > {let input ='{"1": null} 'let y = match (input) let v = y ({' 1equal: null}) let w = y ([null, 1]) expect (v) .toEqual (true) expect (w) .toEqual (false)}) to this I believe you have a deeper understanding of "how to understand the js object schema", so you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Objects properties patterns content more learning support utility deeper special interest prototype instance practicality practicality simplicity of operation method friend ellipsis website Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Microsoft Xiaomi MySQL Redmi