Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the js object schema

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report