ES6 object assignment and Symbol
This time I will bring you the assignment and Symbol of ES6 objects. What are the precautions for using the assignment and Symbol of ES6 objects? The following is a practical case, let's take a look.
//es6语法允许变量直接为对象的赋值,快捷方便; let liu="呵呵哒"; let long="赖皮哒"; let a={liu,long}; console.log(a) ; //es6语法允许为对象构建key值; let key='skill'; var obj={ [key]:'web'} console.log(obj.skill); //es6语法允许直接合并对象; let s={liuliu:"wowoda",age:20}; let ss={long:"赖皮"}; let sss=Object.assign(s,ss); console.log(sss); //object.is()方法判断是否相等;
type conversion during comparison, while the three equal signs will not. If the type Different, it will return false directly,
and Object.is() is based on the third equal sign, and specially handles NaN, -0, +0, ensuring that -0 and +0 are no longer Same, But it should be noted that Object.is(NaN, NaN) will return true Symbol: As a newdata type was born in es6 : Symbol literally means symbolic, representing the uniqueness of something;
let myId=Symbol(); let myname=Symbol(); console.log (myname) ===>Symbol() typeof myname ===>symbol console.log(myId===myname) ===>false
String; it cannot be operated with other types ;It cannot be converted implicitly;
A Symbol() can be considered as a new function created in memory (so it is not wrong to say that parentheses are the symbol of a function); The Symbol function can also pass in parameters; the parameters are only used as a description of this Symbo;let myId=Symbol("id"); let myname=Symbol("名字");
attribute to ensure uniqueness;
let system=Symbol(); let foo={}; foo[system]="windows"; //还可以保证key值为symbol类型的不被 for in遍历出来; //同样还证明了一点:对象的访问方式,要么以 . ;要么以["这里必须是字符串"];js的底层全部是字符串这种实现; console.log(foo);
let sy=Symbol.for("aaa");
let cccc=Symbol.for("aaa");
Detailed explanation of destructuring assignment in ES6
Detailed explanation of scope and declaration of variables in ES6
The above is the detailed content of ES6 object assignment and Symbol. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

You can easily copy and paste text and files between VMware virtual machines (VMs) and physical systems. This capability allows you to easily transfer images, formatted and unformatted text, and even email attachments between virtual machines and host systems. This article will show you how to enable this feature and demonstrate methods for copying data, files, and folders. How to Enable Copy/Paste in VMware VMware provides three different ways to copy data, files or folders from a virtual machine to a physical computer and vice versa, as explained below: Copy and Paste Elements Drag and Drop Feature Folder Sharing 1 ] Enable copy-paste using VMware Tools You can use the keyboard if your VMWare installation and guest operating system meet the requirements

Want to copy a page in Microsoft Word and keep the formatting intact? This is a smart idea because duplicating pages in Word can be a useful time-saving technique when you want to create multiple copies of a specific document layout or format. This guide will walk you through the step-by-step process of copying pages in Word, whether you are creating a template or copying a specific page in a document. These simple instructions are designed to help you easily recreate your page without having to start from scratch. Why copy pages in Microsoft Word? There are several reasons why copying pages in Word is very beneficial: When you have a document with a specific layout or format that you want to copy. Unlike recreating the entire page from scratch

JSON (JavaScriptObjectNotation) is a lightweight data exchange format that has become a common format for data exchange between web applications. PHP's json_encode() function can convert an array or object into a JSON string. This article will introduce how to use PHP's json_encode() function, including syntax, parameters, return values, and specific examples. Syntax The syntax of the json_encode() function is as follows: st

Use Python's __contains__() function to define the containment operation of an object. Python is a concise and powerful programming language that provides many powerful features to handle various types of data. One of them is to implement the containment operation of objects by defining the __contains__() function. This article will introduce how to use the __contains__() function to define the containment operation of an object, and give some sample code. The __contains__() function is Pytho

Here's how to convert a MySQL query result array into an object: Create an empty object array. Loop through the resulting array and create a new object for each row. Use a foreach loop to assign the key-value pairs of each row to the corresponding properties of the new object. Adds a new object to the object array. Close the database connection.

Wedge We know that objects are created in two main ways, one is through Python/CAPI, and the other is by calling a type object. For instance objects of built-in types, both methods are supported. For example, lists can be created through [] or list(). The former is Python/CAPI and the latter is a calling type object. But for instance objects of custom classes, we can only create them by calling type objects. If an object can be called, then the object is callable, otherwise it is not callable. Determining whether an object is callable depends on whether a method is defined in its corresponding type object. like

On Mac, it's common to need to copy and paste content between different documents. The macOS clipboard only retains the last copied item, which limits our work efficiency. Fortunately, there are some third-party applications that can help us view and manage our clipboard history easily. How to View Clipboard Contents in Finder There is a built-in clipboard viewer in Finder, allowing you to view the contents of the current clipboard at any time to avoid pasting errors. The operation is very simple: open the Finder, click the Edit menu, and then select Show Clipboard. Although the function of viewing the contents of the clipboard in the Finder is small, there are a few points to note: the clipboard viewer in the Finder can only display the contents and cannot edit them. If you copied

This article will show you how to enable or disable automatic copying of selections to the clipboard in Windows Terminal. Windows Terminal is a multi-tab terminal emulator developed by Microsoft specifically for Windows 11/10, replacing the traditional command prompt. It supports running applications such as Command Prompt, PowerShell, WSL, Azure, etc. Often when working in the terminal, users need to copy commands and output, however the terminal does not support copying selection operations by default. Keep reading this article to learn how to fix this issue. How to enable or disable automatic copying of selections to cache in Terminal? Here's how you can enable or disable automatic copying of selections to the Terminal clipboard: Open the Terminal application and click above
