From 01b0e12ba27b5069248fd09235e9a7143915ee30 Mon Sep 17 00:00:00 2001 From: Irvin Date: Wed, 16 Feb 2022 02:02:49 +0800 Subject: remove `notranslate` class in zh-CN --- .../reference/global_objects/object/create/index.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'files/zh-cn/web/javascript/reference/global_objects/object/create') diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/create/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/create/index.html index 073605d77f..671c542a48 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/create/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/create/index.html @@ -20,7 +20,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/create

语法

-
Object.create(proto,[propertiesObject])
+
Object.create(proto,[propertiesObject])

参数

@@ -45,7 +45,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/create

下面的例子演示了如何使用Object.create()来实现类式继承。这是一个所有版本JavaScript都支持的单继承。

-
// Shape - 父类(superclass)
+
// Shape - 父类(superclass)
 function Shape() {
   this.x = 0;
   this.y = 0;
@@ -77,7 +77,7 @@ rect.move(1, 1); // Outputs, 'Shape moved.'

如果你希望能继承到多个对象,则可以使用混入的方式。

-
function MyClass() {
+
function MyClass() {
      SuperClass.call(this);
      OtherSuperClass.call(this);
 }
@@ -98,7 +98,7 @@ MyClass.prototype.myMethod = function() {
 
 

使用 Object.createpropertyObject参数

-
var o;
+
var o;
 
 // 创建一个原型为null的空对象
 o = Object.create(null);
@@ -167,7 +167,7 @@ o2 = Object.create({}, {
 
 

请注意,尽管在 ES5 中 Object.create支持设置为[[Prototype]]null,但因为那些ECMAScript5以前版本限制,此 polyfill 无法支持该特性。

-
if (typeof Object.create !== "function") {
+
if (typeof Object.create !== "function") {
     Object.create = function (proto, propertiesObject) {
         if (typeof proto !== 'object' && typeof proto !== 'function') {
             throw new TypeError('Object prototype may only be an Object: ' + proto);
-- 
cgit v1.2.3-54-g00ecf