当前位置:网站首页>JS static method
JS static method
2022-06-30 04:09:00 【Runqing】
es5:
let Person = function (type) {
this.type = type
}
// Static methods
Person.breathe = function () {
console.log('breathing')
}
// The archetypal approach
Person.prototype.speak = function () {
Person.breathe()
console.log('hhhhhh')
}
let student = new Person('student')
student.speak()
// breathing
// hhhhhh
es6:
class Person {
constructor (type) {
this.type = type
}
// Static methods
static breathe () {
console.log('breathing')
}
// The archetypal approach
speak = function () {
Person.breathe()
console.log('hhhhhh')
}
}
let student = new Person('student')
student.speak()
// breathing
// hhhhhh
边栏推荐
- Do280 private warehouse persistent storage and chapter experiment
- [Thesis reading | deep reading] role2vec:role based graph embeddings
- Error in conditional filter (if) syntax in sum function in SQL Server2005
- Integrating viewbinding and viewholder with reflection
- 将DataBinding整合到Activity/Fragment的一种极简方式
- dotnet-exec 0.5.0 released
- Day 10 data saving and loading
- 2021-07-05
- GIS related data
- Introduction to cloud native + container concept
猜你喜欢

Selenium environment installation, 8 elements positioning --01

【云原生】AI云开发平台——AI Model Foundry介绍(开发者可免费体验AI训练模型)

lego_loam 代码阅读与总结

第十天 数据的保存与加载

(Reprinted) an article will take you to understand the reproducing kernel Hilbert space (RKHS) and various spaces

声网自研传输层协议 AUT 的落地实践丨Dev for Dev 专栏

你清楚AI、数据库与计算机体系

NER中BiLSTM-CRF解读score_sentence

【论文阅读|深读】DANE:Deep Attributed Network Embedding

I get n offers in two months. I don't have any difficult interviewers here
随机推荐
How to analyze and solve the problem of easycvr kernel port error through process startup?
Grasp grpc communication framework in simple terms
云原生——Web实时通信技术之Websocket
Jour 9 Gestion des scripts et des ressources
Green new power and "zero" burden of computing power -- JASMINER X4 series is popular
base64.c
基于ROS的SLAM建图、自动导航、避障(冰达机器人)
Blue Bridge Cup: magic cube rotation [Vocational group]
Node red series (28): communication with Siemens PLC based on OPC UA node
El upload Upload file (Manual upload, Automatic upload, upload progress)
第十二天 进阶编程技术
NER中BiLSTM-CRF解读score_sentence
基于海康EhomeDemo工具排查公网部署出现的视频播放异常问题
SQL append field
Day 11 script and game AI
Implementation of aut, a self-developed transport layer protocol for sound network -- dev for dev column
知识点滴 - 如何用3个简单的技巧在销售中建立融洽的关系
【图像融合】基于交叉双边滤波器和加权平均实现多焦点和多光谱图像融合附matlab代码
[punch in - Blue Bridge Cup] day 1 --% 7F format output
After the win10 system uses the browser to download, the content is moved or deleted without reason