[prototype and prototype chain] what is prototype and prototype chain [key!!]

Time:2022-5-20

As we all know, hard work is the only way to success!

[prototype and prototype chain] what is prototype and prototype chain [key!!]

。 The picture comes from the network # if there is infringement # contact to delete.

1、 Prototype

① All reference types have one__ proto__ (implicit prototype) attribute. The attribute value is an ordinary object

② All functions have a prototype attribute, and the attribute value is an ordinary object

③ Of all reference types__ proto__ Property points to the prototype of its constructor

var a = [1,2,3];

a.__proto__ === Array.prototype; // true

2、 Prototype chain

When accessing a property of an object, you will first find it on the property of the object itself,

If you don’t find it, you’ll go to it__ proto__ Search on the implicit prototype, that is, the prototype of its constructor,

If it is not found, it will be in the prototype of the constructor__ proto__ Find in,

In this way, looking up layer by layer will form a chain structure, which is called prototype chain.

For example, there are the following codes:

function Parent(month){

    this.month = month;

}

var child = new Parent(‘Ann’);

console.log(child.month); // Ann

console.log(child.father); // undefined

When finding an attribute in child, the following steps are performed:

[prototype and prototype chain] what is prototype and prototype chain [key!!]

As shown in the figure


The access link is:

[prototype and prototype chain] what is prototype and prototype chain [key!!]

As shown in the figure


① Search to the upper layer until null is not found, then undefined is returned

②Object.prototype.__proto__ === null

③ All the methods obtained and executed from the prototype or higher-level prototype. When executing, this points to the object of the current trigger event

[prototype and prototype chain] what is prototype and prototype chain [key!!]

Recommended Today

UI automation test: Selenium + Po mode + pytest + allure integration

本人目前工作中未涉及到WebUI自动化测试,但为了提升自己的技术,多学习一点还是没有坏处的,废话不多说了,目前主流的webUI测试框架应该还是selenium,考虑到可维护性、拓展性、复用性等,我们采用PO模式去写我们的脚本,本文档也主要整合了Selenium+PO模式+Pytest+Allure,下面我们进入正题。注:文章末尾附Github地址 技术前提:python、selenium、pytest基础知识 1. 项目结构目录: image.png 2. PO模式介绍 PO模式特点: 易于维护 复用性高 脚本易于阅读理解 PO模式要素: 1. 在PO模式中抽象封装成一个BasePage类,该基类应该拥有一个只实现 webdriver 实例的属性 2. 每个一个 pag 都继承BasePage,通过driver来管理本page中元素将page中的操作封装成一个个的方法 3. TestCase依赖 page 类,从而实现相应的测试步骤 2019062515512657.png 3. BasePage 页面封装 import logging import os import time from datetime import datetime from time import sleep from selenium import webdriver from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.wait import […]