From 0016c74a9255332c793969dd194d5c4809e7f452 Mon Sep 17 00:00:00 2001 From: nanshu <56244178+LuckyChou710@users.noreply.github.com> Date: Fri, 11 Mar 2022 01:50:17 +0800 Subject: remove Object.assign polyfill (#4392) There are two polyfills --- .../global_objects/object/assign/index.html | 33 ---------------------- 1 file changed, 33 deletions(-) (limited to 'files/zh-cn/web/javascript/reference/global_objects') diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/assign/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/assign/index.html index 4b8696d2ab..616406e3e5 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/assign/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/assign/index.html @@ -251,39 +251,6 @@ console.log(copy); // { foo:1, get bar() { return 2 } } -
此{{Glossary("Polyfill","polyfill")}}不支持 symbol 属性,因为ES5 中根本没有 symbol :
- -if (typeof Object.assign != 'function') {
- // Must be writable: true, enumerable: false, configurable: true
- Object.defineProperty(Object, "assign", {
- value: function assign(target, varArgs) { // .length of function is 2
- 'use strict';
- if (target == null) { // TypeError if undefined or null
- throw new TypeError('Cannot convert undefined or null to object');
- }
-
- let to = Object(target);
-
- for (var index = 1; index < arguments.length; index++) {
- var nextSource = arguments[index];
-
- if (nextSource != null) { // Skip over if undefined or null
- for (let nextKey in nextSource) {
- // Avoid bugs when hasOwnProperty is shadowed
- if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
- to[nextKey] = nextSource[nextKey];
- }
- }
- }
- }
- return to;
- },
- writable: true,
- configurable: true
- });
-}